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

我在centos 7.3 </ code>上部署一个php项目,有一个错误 connect()失败</ code>。</ p>

nginx </ code>和 php </ code>和 mariadb </ code>一直在运行, 我可以访问nginx的欢迎页面。</ p>

  [root @ demo~] #systemctl list-unit-files --type = service |  grep enabled 
// ...

nririb。服务已启用
mysql.service已启用
mysqld.service已启用
nginx.service已启用

php-fpm.service已启用
// ...
</ code> < / pre>

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

nginx配置是这样的: /etc/nginx/conf.d /default.conf


nn
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;
}
</ code> </ pre> \ n

php配置如下: /etc/php-fpm.d/www.conf </ code> </ p>

  #listen = / run   /var/log/nginx/error.log </ cod中的/php-fpm.sock
listen = 127.0.0.1:9000

nn

错误 e>:</ p>

  //使用unix:/ run / php-fpm.sock
connect()到unix的错误:/run/php-fpm.sock 连接到上游上游时失败(2:没有这样的文件或目录):“fastcgi:// unix:/run/php-fpm.sock:”

//使用127.0.0.1:9000的错误 :
connect()失败(111:拒绝连接),同时连接到上游,上游:“fastcgi://127.0.0.1:9000”
</ code> </ pre>

我该怎么办? 做?</ p>
</ div>

展开原文

原文

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?

duanjizi9443
duanjizi9443 你重启了php-fpm吗?systemctl重启php-fpm。还添加systemctlstatusphp-fpm,sudolsof-cphp-fpm-a-i4的输出
大约 3 年之前 回复
dpfwhb7470
dpfwhb7470 nginx没有运行,或者配置错误。检查sudo服务--status-all以确保nginx旁边有一个加号,并尝试重新启动它。
大约 3 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐