duanqiaoren9975 2017-09-11 13:34
浏览 96

在centos 7.3上的php`connect()failed`

I am deploying a php project on centos 7.3 , there is an error connect() failed .

nginx and php and mariadb has been running,and I can access the welcome page of nginx.

[root@demo ~]# systemctl list-unit-files --type=service | grep enabled
//...
mariadb.service                               enabled 
mysql.service                                 enabled 
mysqld.service                                enabled 
nginx.service                                 enabled 
php-fpm.service                               enabled 
//...

Then,I upload a php project to this centos server.

nginx configuration is like this: /etc/nginx/conf.d/default.conf

location ~ \.php$ {
    root           /var/www/project/public;
    #fastcgi_pass   unix:/run/php-fpm.sock;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    include        fastcgi_params;
}

php configuration is like this: /etc/php-fpm.d/www.conf

#listen = /run/php-fpm.sock
listen = 127.0.0.1:9000

error in /var/log/nginx/error.log

//error of using `unix:/run/php-fpm.sock`:
connect() to unix:/run/php-fpm.sock failed (2: No such file or directory) while connecting to upstream, upstream: "fastcgi://unix:/run/php-fpm.sock:"

//error of `using 127.0.0.1:9000`:
connect() failed (111: Connection refused) while connecting to upstream, upstream: "fastcgi://127.0.0.1:9000"

What should I do?

  • 写回答

0条回答 默认 最新

    报告相同问题?