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

时间:2017-09-11 13:34:11

标签: php linux nginx

我正在centos 7.3部署一个php项目,错误connect() failed

nginxphp以及mariadb一直在运行,我可以访问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 
//...

然后,我将一个php项目上传到这个centos服务器。

nginx配置如下:/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配置如下:/etc/php-fpm.d/www.conf

#listen = /run/php-fpm.sock
listen = 127.0.0.1:9000
/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"

我该怎么办?

0 个答案:

没有答案