Nginx与php-fpm使用TCP套接字方式链接

之前在配置yaf框架项目时,报出了connect() failed (111: Connection refused) while connecting to upstream,,定位到是nginx配置文件server段的配置与php-fpm.conf里面配置的链接方式不同造成的

  • 修改php-fpm.conf的配置文件

注释掉listen = /tmp/php-cgi.sock;listen.allowed_clients = 127.0.0.1

[www]
;listen = /tmp/php-cgi.sock
listen = 127.0.0.1:9000
listen.backlog = -1
;listen.allowed_clients = 127.0.0.1
listen.owner = www
listen.group = www
  • 修改nginx配置文件的服务配置
    将fastcgi_param更换为127.0.0.1:9000
location ~ \.php {
            try_files $uri =404;
            include /usr/local/nginx/conf/fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
            fastcgi_pass 127.0.0.1:9000;
            set $path_info "";
            set $real_script_name $fastcgi_script_name;
            if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
                set $real_script_name $1;
                set $path_info $2;
            }
            fastcgi_param SCRIPT_NAME $real_script_name;
            fastcgi_param PATH_INFO $path_info;
    }

你可能感兴趣的:(Linux,Unix,nginx)