mysql : sudo apt-get install mysql-server mysql-client 
nginx:
sudo apt-get install nginx

安装Nginx稳定版本
sudo apt-get install python-software-properties

sudo add-apt-repository ppa:nginx/stable

sudo apt-get update

sudo apt-get install nginx

启动
sudo service nginx start

安装PHP

sudo apt-get install php5-fpm
  php测试页
sudo vi /usr/share/nginx/html/info.php
<?php
phpinfo();
?>

修改nginx的配置

server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
#网站根目录
root /usr/share/nginx/html;
#增加index.php
index index.php index.html index.htm;

# Make site accessible from http://localhost/
#绑定域名
server_name localhost;

location / {

try_files $uri $uri/ =404;

}

location /doc/ {
alias /usr/share/doc/;
autoindex on;
allow 127.0.0.1;
allow ::1;
deny all;
}

#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

location ~ \.php$ {

# With php5-fpm:
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}

  

proxy_conf¶

proxy_redirect          off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffers 32 4k;

  

fastcgi_conf

fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name; fastcgi_index index.php; fastcgi_param REDIRECT_STATUS 200;

  

mime_types

types {
text/html html htm shtml;
text/css css;
text/xml xml rss;
image/gif gif;
image/jpeg jpeg jpg;
application/x-javascript js;
text/plain txt;
text/x-component htc;
text/mathml mml;
image/png png;
image/x-icon ico;
image/x-jng jng;
image/vnd.wap.wbmp wbmp;
application/java-archive jar war ear;
application/mac-binhex40 hqx;
application/pdf pdf;
application/x-cocoa cco;
application/x-java-archive-diff jardiff;
application/x-java-jnlp-file jnlp;
application/x-makeself run;
application/x-perl pl pm;
application/x-pilot prc pdb;
application/x-rar-compressed rar;
application/x-redhat-package-manager rpm;
application/x-sea sea;
application/x-shockwave-flash swf;
application/x-stuffit sit;
application/x-tcl tcl tk;
application/x-x509-ca-cert der pem crt;
application/x-xpinstall xpi;
application/zip zip;
application/octet-stream deb;
application/octet-stream bin exe dll;
application/octet-stream dmg;
application/octet-stream eot;
application/octet-stream iso img;
application/octet-stream msi msp msm;
audio/mpeg mp3;
audio/x-realaudio ra;
video/mpeg mpeg mpg;
video/quicktime mov;
video/x-flv flv;
video/x-msvideo avi;
video/x-ms-wmv wmv;
video/x-ms-asf asx asf;
video/x-mng mng;
}

  



修改默认站点
sudo vi /etc/nginx/sites-available/default 在这里您可以定义根目录,你的网站域名,以及其他设置
下面是例子
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on; root /usr/share/nginx/html;
index index.php index.html index.htm; # Make site accessible from http://localhost/
server_name localhost; location / { try_files $uri $uri/ /index.php; } location /doc/ {
alias /usr/share/doc/;
autoindex on;
allow 127.0.0.1;
allow ::1;
deny all;
} #
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
} location ~ \.php$ { # With php5-fpm:
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
} # deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}

 修改完以后 重启

sudo service nginx reload

安装Xcache,一个自由和开放的PHP操作码缓存和优化PHP中间代码隐藏自己,以及其他PHP模块:
sudo apt-get install php5-mysql php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl php5-xcache

sudo service php5-fpm restart重启

 








ubuntu下安装nginx -php的更多相关文章

  1. Ubuntu下安装Nginx,PHP5(及PHP-FPM),MySQL

    .简介: Tomcat在高并发环境下处理动态请求时性能很低,而在处理静态页面更加脆弱.虽然Tomcat的最新版本支持epoll,但是通过Nginx来处理静态页面要比通过Tomcat处理在性能方面好很多 ...

  2. 转- 在ubuntu下安装Nginx

    一. 安装包安装 1.1 安装Nginx $sudo apt-get install nginx Ubuntu安装之后的文件结构大致为: 所有的配置文件都在/etc/nginx下,并且每个虚拟主机已经 ...

  3. ubuntu下安装 nginx + php + memcached + mariadb

    一,apt-get 安装 1,安装nginx sudo apt-get install nginx 所有的配置文件都在/etc/nginx下,虚拟主机配置在/etc/nginx/sites-avail ...

  4. Ubuntu下安装Nginx

    转载自:http://www.cnblogs.com/skynet/p/4146083.html 1.Nginx安装 我使用的环境是64位 Ubuntu 14.04, Nginx是Nginx 1.10 ...

  5. Ubuntu下安装Nginx详细步骤

    Nginx安装之前需要三个支持: 模块依赖性 ①gzip 模块需要 zlib 库 ②rewrite 模块需要 pcre 库 ③ssl 功能需要 openssl 库 预先编译好的包: sudo apt- ...

  6. Ubuntu下安装nginx及使用

    首先介绍以下nginx.下图来自百科介绍:详细介绍地址:https://baike.baidu.com/item/nginx/3817705?fr=aladdin 在我们平时的开发娱乐中,也许并不会涉 ...

  7. ubuntu 下安装nginx

    y@y:~$ sudo apt-get install nginx y@y:~$ sudo service nginx start y@y:~$ nginx默认使用80端口,打开浏览器输入:http: ...

  8. Ubuntu下安装与卸载Nginx

    1.Ubuntu下安装Nginx比较简单 敲入下列命令即可: sudo apt-get update sudo apt-get install nginx 2.Ubuntu下卸载,稍不注意就会入坑 s ...

  9. Ubuntu下安装LNMP之php7的安装并配置Nginx支持php及卸载php

    据了解,php7是比之前的版本性能快很多的.http://php.net/get/php-7.2.2.tar.gz/from/a/mirror 安装前也可提前将相关依赖库安装好,或者在安装php时若安 ...

随机推荐

  1. 上海hande

    HZero UI 一个服务于企业级产品的设计体系,基于『确定』和『自然』的设计价值观和模块化的解决方案,让设计者专注于更好的用户体验. Choerodon UI of React Choerodon ...

  2. Hadoop框架:NameNode工作机制详解

    本文源码:GitHub·点这里 || GitEE·点这里 一.存储机制 1.基础描述 NameNode运行时元数据需要存放在内存中,同时在磁盘中备份元数据的fsImage,当元数据有更新或者添加元数据 ...

  3. linq 整理(前序)

    前言 对linq进行整理,分为前序.中序和后序. 前序就是一些简单的概念和模拟. 中序的话就是深挖一些思想. 后序对其进行解刨. 正文 语言集成查询 (LINQ) 是一系列直接将查询功能集成到 C# ...

  4. linux(centos8):安装分布式事务服务seata(file单机模式,seata 1.3.0/centos 8.2)

    一,什么是seata? Seata:Simpe Extensible Autonomous Transcaction Architecture, 是阿里中间件,开源的分布式事务解决方案. 前身是阿里的 ...

  5. echo 输出颜色

    shell脚本里使用echo输出颜色       echo命令颜色显示: echo:      -n:  不换行.      -e:让转移符生效. \t(tab) \n (换行) 实例: $ echo ...

  6. 皕杰报表:连接数据库失败,请检查数据源配置(oracle.jdbc.driver.OracleDriver)

    皕杰报表:连接数据库失败,请检查数据源配置(oracle.jdbc.driver.OracleDriver)问题解决: 缺少了classes12.jar 在窗口--首选项--报表运行时配置--添加-- ...

  7. CPU 底层运算之乘法运算

    CPU 运算加减法运算 假设计算  3+3  原码是0011 * 0011(以4位存贮单元,因为是原码,最高位不代表符号位) 1. 首先 判断 两个加数是否有 负数(减法)  如果有 负数 先将负数转 ...

  8. 通过IIS部署,将图片或者视频等文件用http协议网址访问

    打开IIS管理器 又键点击添加网站 然后到这个界面 文件夹里有这些图片,随便用的一些图片 然后我这里用的是局域网测试,所以IP就是wifi的IP地址,如果是服务器的话,直接选服务器本身的IP地址就行了 ...

  9. .gdbinit文件配置

    .gdbinit文件配置 #打印数组的索引下标 set print array-indexes on #每行打印一个结构体成员 set print pretty on #除了断点有关的线程会被停下来, ...

  10. python图片验证码识别最新模块muggle_ocr

    一.官方文档 https://pypi.org/project/muggle-ocr/ 二模块安装 pip install muggle-ocr # 因模块过新,阿里/清华等第三方源可能尚未更新镜像, ...