ngnix+php 部署成功,但是找网站的时候报404错误

server {
server_name localhost 192.168.179.130
listen 80;
root /usr/local/webserver/data/www/b2b2c/public/;
index index.php index.html index.htm;

……
location = /50x.html {
root html;
}

location /index.php {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/webserver/data/www/public$fastcgi_script_name;
include fastcgi_params;
}

第1个回答  2015-12-08
你看看我的这个回答对你行不行
静态页面的index.html 是可以访问的,而动态的info.php确是404 找不到,为什么会这样那?index.html 文件目录是nginx默认安装目录 /usr/local/nginx/html,而
info.php 我把它放到了 /data/web 下 是不是这个原因 ?看下nginx.conf配置文档
server {
listen 80;
server_name localhost;

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

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
}

过程
尝试更改下
location ~ \.php$ {
root /data/web;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
nginx -t && nginx -s reload
测试访问仍然不行
google
再次更改
location ~ \.php$ {
root /data/web;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /data/web$fastcgi_script_name;
include fastcgi_params;
}
nginx -t && nginx -s reload
测试一下
[root@me zongm]# curl -I
HTTP/1.1 200 OK
Server: nginx/1.0.5
Date: Mon, 01 Aug 2011 08:34:17 GMT
Content-Type: text/html
Connection: keep-alive
X-Powered-By: PHP/5.3.6
firefox 测试ok!
你试试我这个过程看看,希望我的回答对你有用,如果还有其他的问题,可以去后盾网论坛问题求助专区去提问,会让你有更多收益!追问

路径是对的,在该路径下,自己写的1.php是可以读出来的,就是index.php不行! 不过还是要谢谢!

追答

去后盾网论坛问

本回答被网友采纳
相似回答