我从 Apache 更改为 Nginx,现在遇到了一些问题。
http://devserver/monitor/web我有一个 Symfony 项目,我收到 404 错误http://devserver我一直收到这条消息File not found.这是我的/etc/nginx/conf.d/default.conf文件的样子:
server {
listen 80;
server_name devserver;
location / {
root /var/www/html;
index index.php;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
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;
}
}
Run Code Online (Sandbox Code Playgroud)
有什么问题吗?
你把你的root指令放在了错误的地方。
root应该在server块中定义,而不是在每个location块中定义。这是最常见的 nginx 配置错误之一。
要解决此问题,请root从每个location块中删除所有指令,并将正确的root指令放在server块中,而不是放在任何location.
root放在location块中的唯一原因是当您实际上想要一个不同的文档根目录时location,例如用于提供 nginx 默认错误消息(正如您在此处所做的那样)。
| 归档时间: |
|
| 查看次数: |
7946 次 |
| 最近记录: |