最近我重新安装了一台装有 Ubuntu 14.04 LTS、nginx/1.6.1 和 php5-fpm 的服务器。当我尝试访问 index.html 时,它正常工作,而当我尝试访问 index.php 时,我收到“404 Not Found”错误。我仔细检查了 .conf 文件,但找不到问题所在。
server {
listen m.y.i.p:80;
server_name www.example.com;
rewrite ^(.*) http:// example.com$1 permanent;
}
server {
listen m.y.i.p:80;
server_name example.com;
root /var/www;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.html;
}
access_log off;
error_log /var/www/error.log;
rewrite_log on;
error_page 403 404 /404.html;
error_page 500 502 503 504 /404.html;
location = /404.html {
root /var/www;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
#fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
expires 365d;
}
}
请帮忙。谢谢!
答案1
由于结果是“502 Bad Gateway”,而不是“404 Not Found”,我在这里找到了问题的答案 https://stackoverflow.com/a/16497957/1845728。