dpj0015 2015-01-26 15:35
浏览 229
已采纳

nginx没有生成任何php-fpm.sock任何人有任何想法为什么?

I have recently built a new web server using the (LEMP) method and it's all running good, I also installed Varnish and phpMyAdmin into the lemp install.

I added unix: /var/run/php-fpm/php-fpm.sock to the location / {

Then I told www.conf to listen to /var/run/php-fpm/php-fpm.sock

however nginx isn't generating any sockets to the /var/run/php-fpm folder.

All the services are running correctly and I can access the default webpage at my-ip but trying to access anything else i.e my-ip/anythingelse gives me 502 bad gateway because it's not finding the socket.

Does anyone know what could be the cause and a fix?

Here's my 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:* LISTEN 4046/varnishd
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 3988/php-fpm: maste 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:* LISTEN 1559/rpc.statd
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1362/rpcbind
tcp 0 0 127.0.0.1:80 0.0.0.0:* LISTEN 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:* LISTEN 1361/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 3500/cupsd
tcp6 0 0 ::1:25 :::* LISTEN 2519/master
tcp6 0 0 :::33209 :::* LISTEN 1559/rpc.statd
tcp6 0 0 :::111 :::* LISTEN 1362/rpcbind
tcp6 0 0 :::22 :::* LISTEN 1361/sshd
tcp6 0 0 ::1:631 :::* LISTEN 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 ~]#

  • 写回答

2条回答 默认 最新

  • douqian3712 2015-01-26 20:59
    关注

    I have solved the issue and figured out why it wasn't creating the socket...

    I thought I would take extra precautions with the files I was editing and created backups in the folders... Well because of this it was including the .conf's twice which is why it was still using 127.0.0.1:9000 even though I told it to use /var/run/php-fmp/php-fpm.sock ... lesson learned - (put backups in a separate root folder.

    Have another wee issue now though. *2 FastCGI sent in stderr "Primary script unknown" while reading response header from upstream?

    Thank you for a push in the right direction... Had you not of mentioned to do a netstat I probably wouldn't have thought about the backup files.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥50 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?