我使用PHP7.0运行LEMP。
我已经在我的服务器块
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
但是,当我打开该网站时,它会返回502错误的网关。 以下是错误日志。
*1 connect() to unix:/var/run/php/php7.0-fpm.sock failed (13: Permission denied) while connecting to upstream, client: xxx.xxx.xxx.xxx, server: example.com, request: "GET / HTTP1.1", upstream: "fsatcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "example.com"
它说权限被拒绝 。 这里有什么问题? 我已经检查,但我似乎无法find什么需要给予什么样的权限。
谢谢。
我得到了它的工作。
php用户是www-data但nginx用户是nginx 。
在这里检查php:/etc/php/7.0/fpm/pool.d/www.conf
listen.owner = www-data listen.group = www-data listen.mode = 0660
Nginx的用户位于/etc/nginx/nginx.conf
这引导了我: https : //stackoverflow.com/questions/23443398/nginx-error-connect-to-php5-fpm-sock-failed-13-permission-denied
我通过以下步骤解决了同样的问题。
打开你的http://www.conf文件(例如:sudo nano /etc/php-fpm.d/www.conf)最后,find设置listen.owner和listen.group的行,并将它们的值从“nobody”更改为“nginx “:
listen.owner = nginx listen.group = nginx listen.mode = 0666
最后,find设置用户和组的行,并将其值从“apache”更改为“nginx”:
user = nginx group = nginx
重新启动php-fpm(sudo服务php-fpm restart)
vim /etc/php-fpm.d/www.conf 以这种方式改变 ; listen.owner = root ; listen.group = root ; listen.owner =没有人 ; listen.group = nobody listen.owner = nginx listen.group = nginx 服务php-fpm重启 服务nginx重启 CentOS版本6.9(最终版)