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

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
    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.

    点赞 评论
  • drblhw5731
    drblhw5731 2015-01-26 20:20

    Nginx is using a socket, while php-fpm listens on port 9000. You can use fastcgi_pass 127.0.0.1:9000; instead in nginx. You can also configure php-fpm to listen on a socket instead following this post.

    点赞 评论

相关推荐