nginx
ubuntu 下配置nginx的pHP
#安装软件包
apt-get install sudo
#更新服务器
sudo apt-get update
#安装常用
sudo apt-get install curl wget vim git
#安装lnmp软件包
#安装nginx
sudo apt-get install nginx
#127.0.0.1测试nginx下如果成功则显示welcome to nginx
#安装mysql
sudo apt-get install mysql-server
#mysql初始配置
sudo mysql_install_db
#mysql安全配置
sudo mysql_secure_installation
#安装PHP
sudo apt-get install php5-fpm
sudo apt-get install php5-mysql
#修改PHP配置
sudo gedit /etc/php5/fpm/php.ini
修改cgi.fix_pathinfo=0
http://www.cnblogs.com/peida/archive/2013/03/18/2965369.html
Nginx配置
配置Nginx支持PHP
sudo vim /etc/nginx/sites-available/default
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;
}
}
#然后重启
sudo service nginx restart
写入info
sudo vim /usr/share/nginx/html/info.php <?php phpinfo(); ?>
重启服务
sudo service php5-fpm restart
sudo service nginx restart