nginx 如何访问php文件

1.进入nginx安装路径,我的是/usr/local/nginx
vi 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;
}

前面的#去掉

location / {
root html;
index index.php index.html index.htm;
}

index.html 前添加index.php
如果说访问nginx还是不能访问,请查看防火墙是否关闭,请关闭防火墙
将上面的fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
改为fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
(其中/usr/local/nginx   是你nginx安装的目录)



posted @ 2019-08-03 21:26  侯蜀黍  阅读(4084)  评论(0编辑  收藏  举报