http://localhost显示的是nginx 1.13的404。当我查看容器日志时,我可以看到nginx没有将请求传递给php-fpm,而是寻找index.html。 我无法弄清楚为什么它不会将请求传递给php-fpm 。
/etc/nginx/conf.d/default.conf
我已验证此文件已加载。
server {
listen 80;
root /var/www/html/public;
index index.php;
charset utf-8;
# look for local files on the container before sending the request to fpm
location / {
try_files $uri /index.php?$query_string;
}
# nothing local, let fpm handle it
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass localhost:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
# Httpoxy exploit (https://httpoxy.org/) fix
fastcgi_param HTTP_PROXY "";
# allow larger POSTS for handling stripe payment tokens
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
}
}
Web容器中的进程列表:
PID USER TIME COMMAND
1 root 0:00 s6-svscan -t0 /var/run/s6/services
33 root 0:00 s6-supervise s6-fdholderd
170 root 0:00 s6-supervise php-fpm
171 root 0:00 s6-supervise nginx
173 root 0:00 php-fpm: master process (/usr/local/etc/php-fpm.conf)
174 root 0:00 {run} /bin/sh ./run
177 root 0:00 nginx: master process nginx -g daemon off;
187 nginx 0:00 nginx: worker process
192 www-data 0:00 php-fpm: pool www
193 www-data 0:00 php-fpm: pool www
194 root 0:00 ps -ef
容器日志
web_1 | 2017/05/13 06:13:10 [error] 187#187: *1 "/etc/nginx/html/index.html" is not found (2: No such file or directory), client: 172.19.0.1, server: localhost, request: "GET / HTTP/1.1", host: "mysite.local"
web_1 | 172.19.0.1 - - [13/May/2017:06:13:10 +0000] "GET / HTTP/1.1" 404 571 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36"
更新根据以下几条评论删除了对index.htm的所有引用
答案 0 :(得分:0)
默认情况下,/etc/nginx/conf.d/
文件夹中的所有配置文件(包括此处/etc/nginx/conf.d/default.conf
的文件)均从/etc/nginx/nginx.conf
扩展。
在此配置中,您未在index
块中指定server {}
指令。然后nginx将在/etc/nginx/nginx.conf
中查找默认值。
解决方法是覆盖默认值:
server {
listen 80;
root /var/www/html/public;
charset utf-8;
index index.php index.html index.htm;
}
然后重置你的nginx:sudo service nginx restart
然后index.php
将优先于其余的nginx进行查找。
答案 1 :(得分:0)
nginx
正在使用index
指令的默认值来处理URI /
(因为目录确实存在)。
您应该向index
块添加明确的server
语句。
server {
...
index index.php;
location / {
try_files $uri /index.php?$query_string;
}
# nothing local, let fpm handle it
location ~ [^/]\.php(/|$) {
...
}
}
有关详情,请参阅this document。
答案 2 :(得分:0)
问题在于,尽管我自己的vhosts配置在let sessionConfiguration = URLSessionConfiguration.background(withIdentifier: <identifier>)
sessionConfiguration.httpMaximumConnectionsPerHost = 4
sessionConfiguration.allowsCellularAccess = AppDelegate.shared.userDefaults.allowsCellularAccess
sessionConfiguration.timeoutIntervalForRequest = 7*60
sessionConfiguration.timeoutIntervalForResource = 24*60*60
let session = URLSession(configuration: sessionConfiguration, delegate:self, delegateQueue: operationQueue)
,/etc/nginx/conf.d/default.conf
(显示nginx加载的配置)并没有显示该文件已被读取。
我nginx -T
中缺少include /etc/nginx/conf.d/*.conf;
指令。