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/任何其他内容都会给我 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 本地地址 外国地址 状态 PID/程序名称
TCP 0 0 127.0.0.1:25 0.0.0.0:* 收听 2519/主
TCP 0 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/清漆
TCP 0 0 127.0.0.1:9000 0.0.0.0:* 收听 3988/php-fpm:桅杆TCP 0 0 127.0.0.1:3306 0.0.0.0:* 收听 2711/mysqld
TCP 0 0 0 0.0.0.0:38350 0.0.0.0:* 收听 1559/rpc.statd
TCP 0 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/清漆
TCP 0 0 127.0.0.1:8080 0.0.0.0:* 收听 4010/nginx:大师
TCP 0 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/主
tcp6 0 0 :::33209 :::* LISTEN 1559/rpc.statd
tcp6 0 0 :::111 :::* 侦听 1362/rpcbind
tcp6 0 0 :::22 :::* 收听 1361/sshd
TCP6 0 0 ::1:631 :::* 收听 3500/杯
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: rudp 0 0 0.0.0.0:5353 0.0.0.0:* 685/avahi-daemon: rudp6 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 配置为在套接字上侦听,而不是在这篇文章之后。

我已经解决了这个问题并弄清楚了为什么它没有创建套接字......

我想我会对我正在编辑的文件采取额外的预防措施,并在文件夹中创建备份......正因为如此,它包含了 .conf 的两次,这就是为什么它仍然使用 127.0.0.1:9000,即使我告诉它使用/var/run/php-fmp/php-fpm.sock ...经验教训 -(将备份放在单独的根文件夹中。

不过现在还有另一个小问题。 *2 FastCGI 在从上游读取响应标头时发送了 stderr"主脚本未知"?

感谢您朝着正确的方向推动...如果你没有提到做一个netstat,我可能不会想到备份文件。