我正在运行PHP71 + Nginx的新Docker环境中工作。 Dockerfileinheritance自million12 / docker –nginx 。
这是/etc/nginx/hosts.d/vhost.conf (我从这里取的 )的内容:
server { listen 80 default_server; listen 81 default_server http2 proxy_protocol; ## Needed when behind HAProxy with SSL termination + HTTP/2 support listen 443 default_server ssl http2; ssl_certificate /etc/nginx/ssl/dummy.crt; ssl_certificate_key /etc/nginx/ssl/dummy.key; root /data/www; index index.php index.html index.htm; location ~ \.php$ { fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } include /etc/nginx/conf.d/stub-status.conf; include /etc/nginx/conf.d/default-*.conf; include /data/conf/nginx/conf.d/default-*.conf; }
我无法find文件下载的原因,而不是显示它的内容。
在容器内部,这是我在/var/run :
# ls -la /var/run/ total 8 drwxr-xr-x 11 root root 185 Dec 14 21:12 . drwxr-xr-x 19 root root 299 Dec 14 21:12 .. drwxr-xr-x 2 root root 6 Sep 5 10:19 blkid drwxr-xr-x 2 root root 6 Jul 29 14:05 console drwxr-xr-x 2 root root 6 Jul 29 14:05 faillock drwxr-xr-x 4 root root 35 Jul 29 14:05 lock drwxr-xr-x 2 root root 6 Jul 29 14:05 log -rw-r--r-- 1 root root 2 Dec 14 21:12 php-fpm.pid drwxr-xr-x 2 root root 6 Jul 29 14:05 sepermit drwxr-xr-x 2 root root 6 Jul 29 14:05 setrans -rw-r--r-- 1 root root 3 Dec 14 21:12 supervisord.pid drwxr-xr-x 9 root root 113 Jul 29 14:05 systemd drwxr-xr-x 2 root root 6 Jul 29 14:05 user -rw-rw-r-- 1 root utmp 0 Jul 29 14:05 utmp
也许这行:
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
工作不正常。 将其更改为:
fastcgi_pass php-upstream;
其中php-upstream是:
upstream php-upstream { server 127.0.0.1:9000; }
也不行。 我被困在这一点上。 我已经检查了所有这些post之前,打开另一个新的:
任何人都可以帮我一下吗? 记住所有这些都在Docker容器中运行,所以也许有些命令不可用。
这是我使用的php-fpm清单。
确保php-fpm已经安装并正在运行
sudo systemctl status php-fpm
在php-fpmconfiguration中检查listen指令
sudo cat /etc/php-fpm.d/www.conf | grep -Ei '^listen'
并确保listen指令与您在nginxconfiguration中设置的上游匹配
如果使用unix套接字,请确保套接字可由php-fpm用户读取/写入(php-fpm用户由www.conf中的user和group指令设置)。 如果使用TCP / IP套接字,请检查以确保php-fpm正在侦听端口:
sudo lsof -i :9000 # or whatever the port number you have specified
尝试从虚拟主机configuration中的“侦听”部分删除http2,看看它是否工作。
当nginx与OpenSSL 1.0.2编译错误时,也有类似的问题。
对我来说,它有助于在/index.php结尾添加?$query_string query_string,如下所示:
location / { try_files $uri $uri/ /index.php?$query_string; }