Ubuntu中搭建Nginx+PHP环境最简单的方法
先安装:
sudo apt-get install nginx php5-fpm
然后编辑配置文件:
sudo gedit /etc/nginx/site-available/default
找到location ~ \.php$的地方,5行取消注释,变成这样:
location ~ \.php$ {
# fastcgi_split_path_info ^(.+\.php)(/.+)$;
# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
#
# # With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
启动php:
/etc/init.d/php5-fpm start
启动nginx:
sudo service nginx start