环境:
1
centos6.5
iptables selinux 关闭
nginx 1.7.9
php 5.5.22
2
vim /usr/local/nginx/conf/nginx.conf
找到这一段内容放开:
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
就改成这样并添加这样的测试index.php:
location / {
root html;
index index.html index.htm index.php;
}
.
.
.
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
测试:
在html下创建一个文件index.php
<?php
phpinfo();
?>
在浏览器上输入IP/index.php
第一个红圈显示程序路径
第二个红圈显示的nginx版本