nginx 没有生成任何 php-fpm.sock 任何人都知道为什么?
nginx isn't generating any php-fpm.sock anyone have any ideas why?
我最近使用 (LEMP) 方法构建了一个新的 Web 服务器,一切都很好 运行,我还在 lemp 安装中安装了 Varnish 和 phpMyAdmin。
我添加了 unix: /var/run/php-fpm/php-fpm.sock 到位置 / {
然后我告诉www.conf听/var/run/php-fpm/php-fpm.sock
但是 nginx 没有为 /var/run/php-fpm 文件夹生成任何套接字。
所有服务都 运行 正确,我可以通过 my-ip 访问默认网页,但尝试访问其他任何内容,即 my-ip/anythingelse 给我 502 错误网关,因为它找不到套接字。
有谁知道可能是什么原因和解决方法?
这是我的 nginx.conf:
user nginx;
worker_processes 4;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/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 /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 60;
include /etc/nginx/conf.d/*.conf;
index index.html index.htm;
server {
listen 127.0.0.1:8080;
root /usr/share/nginx/html;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_split_path_info ^(.+\.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;
}
}
server {
listen 443;
ssl on;
ssl_certificate /etc/nginx/ssl/server.crt;
ssl_certificate_key /etc/nginx/ssl/server.key;
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
root html;
index index.html index.htm;
}
location ~* ^/phpMyAdmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ { root /usr/share/;
}
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_split_path_info ^(.+\.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;
}
}
}
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2519/master
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 4010/nginx: master
tcp 0 0 127.0.0.1:6082 0.0.0.0:* 听 4046/varnishd
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 3988/php-fpm: 主机
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 2711/mysqld
tcp 0 0 0.0.0.0:38350 0.0.0.0:* 收听 1559/rpc.statd
tcp 0 0 0.0.0.0:111 0.0.0.0:* 听 1362/rpcbind
tcp 0 0 127.0.0.1:80 0.0.0.0:* 听 4050/varnishd
tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN 4010/nginx: master
tcp 0 0 0.0.0.0:22 0.0.0.0:* 收听 1361/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* 收听 3500/cupsd
tcp6 0 0 ::1:25 ::::* 收听 2519/master
tcp6 0 0 :::33209 :::* 收听 1559/rpc.statd
tcp6 0 0 :::111 :::* 收听 1362/rpcbind
tcp6 0 0 :::22 :::* 收听 1361/sshd
tcp6 0 0 ::1:631 ::::* 收听 3500/cupsd
udp 0 0 0.0.0.0:59473 0.0.0.0:* 1559/rpc.statd
udp 0 0 0.0.0.0:111 0.0.0.0:* 1362/rpcbind
udp 0 0 0.0.0.0:123 0.0.0.0:* 726/chronyd
udp 0 0 127.0.0.1:323 0.0.0.0:* 726/chronyd
udp 0 0 0.0.0.0:679 0.0.0.0:* 1362/rpcbind
udp 0 0 127.0.0.1:888 0.0.0.0:* 1559/rpc.statd
udp 0 0 0.0.0.0:42032 0.0.0.0:* 685/avahi-daemon: r
udp 0 0 0.0.0.0:5353 0.0.0.0:* 685/avahi-daemon: r
udp6 0 0 :::111 :::* 1362/rpcbind
udp6 0 0 :::123 :::* 726/chronyd
udp6 0 0 ::1:323 ::::* 726/chronyd
udp6 0 0 :::679 :::* 1362/rpcbind
udp6 0 0 :::60779 :::* 1559/rpc.statd
[root@localhost ~]#
Nginx 使用套接字,而 php-fpm 侦听端口 9000。您可以在 nginx 中使用 fastcgi_pass 127.0.0.1:9000;
。您还可以配置 php-fpm 来监听套接字,而不是遵循 this post.
我已经解决了这个问题并弄清楚了为什么它没有创建套接字...
我想我会对正在编辑的文件采取额外的预防措施,并在文件夹中创建备份...正因为如此,它包含了 .conf 两次,这就是为什么它仍在使用 127.0.0.1:9000即使我告诉它使用 /var/run/php-fmp/php-fpm.sock ... 经验教训 - (将备份放在单独的根文件夹中。
不过现在还有一个小问题。 *2 FastCGI 在从上游读取响应 header 时在 stderr "Primary script unknown" 中发送?
感谢您在正确方向上的推动...如果您没有提到做 netstat,我可能不会考虑备份文件。
我最近使用 (LEMP) 方法构建了一个新的 Web 服务器,一切都很好 运行,我还在 lemp 安装中安装了 Varnish 和 phpMyAdmin。
我添加了 unix: /var/run/php-fpm/php-fpm.sock 到位置 / {
然后我告诉www.conf听/var/run/php-fpm/php-fpm.sock
但是 nginx 没有为 /var/run/php-fpm 文件夹生成任何套接字。
所有服务都 运行 正确,我可以通过 my-ip 访问默认网页,但尝试访问其他任何内容,即 my-ip/anythingelse 给我 502 错误网关,因为它找不到套接字。
有谁知道可能是什么原因和解决方法?
这是我的 nginx.conf:
user nginx;
worker_processes 4;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/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 /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 60;
include /etc/nginx/conf.d/*.conf;
index index.html index.htm;
server {
listen 127.0.0.1:8080;
root /usr/share/nginx/html;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_split_path_info ^(.+\.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;
}
}
server {
listen 443;
ssl on;
ssl_certificate /etc/nginx/ssl/server.crt;
ssl_certificate_key /etc/nginx/ssl/server.key;
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
root html;
index index.html index.htm;
}
location ~* ^/phpMyAdmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ { root /usr/share/;
}
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_split_path_info ^(.+\.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;
}
}
}
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2519/master
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 4010/nginx: master
tcp 0 0 127.0.0.1:6082 0.0.0.0:* 听 4046/varnishd
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 3988/php-fpm: 主机
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 2711/mysqld
tcp 0 0 0.0.0.0:38350 0.0.0.0:* 收听 1559/rpc.statd
tcp 0 0 0.0.0.0:111 0.0.0.0:* 听 1362/rpcbind
tcp 0 0 127.0.0.1:80 0.0.0.0:* 听 4050/varnishd
tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN 4010/nginx: master
tcp 0 0 0.0.0.0:22 0.0.0.0:* 收听 1361/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* 收听 3500/cupsd
tcp6 0 0 ::1:25 ::::* 收听 2519/master
tcp6 0 0 :::33209 :::* 收听 1559/rpc.statd
tcp6 0 0 :::111 :::* 收听 1362/rpcbind
tcp6 0 0 :::22 :::* 收听 1361/sshd
tcp6 0 0 ::1:631 ::::* 收听 3500/cupsd
udp 0 0 0.0.0.0:59473 0.0.0.0:* 1559/rpc.statd
udp 0 0 0.0.0.0:111 0.0.0.0:* 1362/rpcbind
udp 0 0 0.0.0.0:123 0.0.0.0:* 726/chronyd
udp 0 0 127.0.0.1:323 0.0.0.0:* 726/chronyd
udp 0 0 0.0.0.0:679 0.0.0.0:* 1362/rpcbind
udp 0 0 127.0.0.1:888 0.0.0.0:* 1559/rpc.statd
udp 0 0 0.0.0.0:42032 0.0.0.0:* 685/avahi-daemon: r
udp 0 0 0.0.0.0:5353 0.0.0.0:* 685/avahi-daemon: r
udp6 0 0 :::111 :::* 1362/rpcbind
udp6 0 0 :::123 :::* 726/chronyd
udp6 0 0 ::1:323 ::::* 726/chronyd
udp6 0 0 :::679 :::* 1362/rpcbind
udp6 0 0 :::60779 :::* 1559/rpc.statd
[root@localhost ~]#
Nginx 使用套接字,而 php-fpm 侦听端口 9000。您可以在 nginx 中使用 fastcgi_pass 127.0.0.1:9000;
。您还可以配置 php-fpm 来监听套接字,而不是遵循 this post.
我已经解决了这个问题并弄清楚了为什么它没有创建套接字...
我想我会对正在编辑的文件采取额外的预防措施,并在文件夹中创建备份...正因为如此,它包含了 .conf 两次,这就是为什么它仍在使用 127.0.0.1:9000即使我告诉它使用 /var/run/php-fmp/php-fpm.sock ... 经验教训 - (将备份放在单独的根文件夹中。
不过现在还有一个小问题。 *2 FastCGI 在从上游读取响应 header 时在 stderr "Primary script unknown" 中发送?
感谢您在正确方向上的推动...如果您没有提到做 netstat,我可能不会考虑备份文件。