# PHP测试文件(放置于Nginx的根目录下)
[root@kazihuo ~]# cat /usr/local/nginx/html/index.php
<?php
phpinfo();
?>
# 修改nginx默认配置文件
[root@kazihuo ~]# cat /usr/local/nginx/conf/nginx.conf|grep 'fastcgi_index' -C 3
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
# 说明
a、fastcgi_pass 用来指定php-fpm监听的地址或者socket;
b、fastcgi_index 设定访问根目录默认去找的文件;
c、fastcgi_param设置访问根目录时默认寻找的文件;
# 重启Nginx
[root@kazihuo ~]# nginx -s reload
# 功能验证