【发布时间】:2014-08-31 10:08:34
【问题描述】:
我在 sites-available 下有一个非常简单的 server 块。
问题:当我尝试访问 mydomain.com 时,Nginx 会返回“404 Not Found”,但如果我尝试访问特别是某个文件,它工作正常,如 mydomain.com/index.php
server {
listen 80;
index index.php;
server_name mydomain.com;
root /home/myusername/sites/mydomain.com/htdocs;
access_log /home/myusername/sites/mydomain.com/logs/access.log;
error_log /home/myusername/sites/mydomain.com/logs/error.log;
location / {
try_files $uri =404;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
请注意:
- 我的 hosts 文件已配置;
- 每次编辑后我都会重新启动 Nginx;
- 访问权限、用户和组正确;
- error.log 文件为空,access.log 向我返回所有 404;
- 我尝试通过添加/删除一些行来更改配置,但仍然没有更改;
- 该站点已在 sites-enabled 中启用,并带有正确的符号链接(我尝试对其进行编辑并打开了正确的文件);
- 我在同一台服务器上有几个运行良好的站点(因此包括 sites-available 和 sites-enabled 是可以的,并且 Nginx 工作正常)。
【问题讨论】:
标签: nginx