centos7上php运行报错:connect() failed

发布于 2022-09-05 22:09:35 字数 1512 浏览 16 评论 0

在centos7上安装好nginx、php、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项目文件夹放上去,却不能访问。采用127.0.0.1:9000unix:/run/php-fpm.sock两种配置方式都不行,配置如下:

/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;
    }

/etc/php-fpm.d/www.conf

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

在nginx的错误日志/var/log/nginx/error.log中,两种配置出现的错误分别如下:

//使用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:"

//使用127.0.0.1:9000的时候错误:
connect() failed (111: Connection refused) while connecting to upstream, upstream: "fastcgi://127.0.0.1:9000"

哪里出了问题?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

皓月长歌 2022-09-12 22:09:35

用sock连接提示文件不存在,端口连接又拒绝连接,那么应该用
netstat之类的查看php-fpm是否监听了9000端口,估计php-fpm的配置有问题。

回忆那么伤 2022-09-12 22:09:35

1.selinux 是否关闭了?
2.php-fpm 服务是否正常启动了?

笑脸一如从前 2022-09-12 22:09:35

用sock转发吧

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文