【发布时间】:2015-04-22 18:43:46
【问题描述】:
很遗憾,我的 nginx 默认页面设置无法正常工作。我已经删除了 /var/www/ 中所有预装的 html 文件,但它仍然可以加载默认的..(也清除了浏览器缓存)
我当前的文件:
nginx.conf
worker_processes 1;
error_log /usr/local/etc/nginx/logs/error.log debug;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /usr/local/etc/nginx/logs/access.log main;
sendfile on;
keepalive_timeout 65;
index index.html index.php;
include /usr/local/etc/nginx/sites-enabled/*;
}
网站可用/默认
server {
listen 80;
server_name localhost;
root /var/www/;
access_log /usr/local/etc/nginx/logs/default.access.log main;
location / {
include /usr/local/etc/nginx/conf.d/php-fpm;
}
error_page 404 /404.html;
error_page 403 /403.html;
}
sites-enabled 包含 sites-available 中文件的别名。
希望我没有错过任何东西!
提前非常感谢您! :)
【问题讨论】:
-
考虑到你把所有东西都扔给了php-fpm,显示的是什么页面? (我想知道 PHP-FPM 是否正在从某个地方提取默认文件。)
-
@kyl191 我使用了以下指南。 blog.frd.mn/… 我怎么知道这个默认页面是从哪里拉出来的?我已经将我所有的 php 文件放入 /var/www/ 任何解决方案?谢谢
-
这个默认页面是什么?你能链接到它的截图吗?访问和错误日志是否说明了什么?
-
副手,我唯一能想到的就是你应该尝试在
include /usr/local/etc/nginx/conf.d/php-fpm;指令下面添加try_files $uri =404,看看你是否可以访问任何静态资源/页面。 (即,只需将任何文件放在 /var/www 中,看看是否可以使用 localhost/file.ext 访问它) -
@kyl191 这是我当前默认页面的截图:imgur.com/rGYPtuW 它是由上面链接的教程设置的。强制执行 404 时,错误日志显示 2015/04/23 22:12:12 [error] 850#0: *4 open() "/var/www404" failed (2: No such file or directory), client: 127.0 .0.1,服务器:localhost,请求:“GET /index.php HTTP/1.1”,主机:“localhost”(为什么它重定向到 /var/www404 而不是 /var/www/404.php - 注意:我改变了将文件类型从 html 转换为 PHP)。插入 try_files 时,即使在现有文件上也会出现连接错误!nginx 启动后(错误日志):imgur.com/lvt4mgn
标签: macos nginx settings default