大网数据广告活动
服务器运维问答

Permission Denied for fastcgi_pass using PHP7

· 52CE 我爱测

I'm running LEMP with PHP7.0. I've got this in my server block fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; But when I open the site, it returns a 502 Bad Gateway. Below is the error log. *1 connect() to unix:/var/run/php/php7…

问题原文

原帖链接 · julio · CC BY-SA 3.0

I'm running LEMP with PHP7.0.

I've got this in my server block

fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;

But when I open the site, it returns a 502 Bad Gateway. Below is the error log.

*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"

It says Permission Denied. What's wrong here? I've checked but I can't seem to find what needs to be given what kind of permission.

Thank you.

已采纳解答

原帖链接 · julio · CC BY-SA 3.0

I got it working.

The php user was www-data but the nginx user was nginx.

Check php here: /etc/php/7.0/fpm/pool.d/www.conf

listen.owner = www-data
listen.group = www-data
listen.mode = 0660

Nginx user was at /etc/nginx/nginx.conf

This guided me: https://stackoverflow.com/questions/23443398/nginx-error-connect-to-php5-fpm-sock-failed-13-permission-denied

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-05-20)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。