博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
php fpm安装curl后,nginx出现connect() to unix:/var/run/php5-fpm.sock failed (13: Permission denied)的错误...
阅读量:6573 次
发布时间:2019-06-24

本文共 2368 字,大约阅读时间需要 7 分钟。

这里选择直接apt-get安装,因为比起自己编译简单多了,不需要自己配置什么

#sudo apt-get install curl libcurl3 libcurl3-dev php5-curl

安装后重启nginx

#nginx -s reload

岂知出现错误,php全部不能访问,查看错误日志如下:

2014/07/24 23:59:46 [crit] 40455#0: *229072 connect() to unix:/var/run/php5-fpm.sock failed (13: Permission denied) while connecting to upstream, client: 171.9

处理方式是:编辑/etc/php5/fpm/pool.d/www.conf文件,将以下的注释去掉:

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

然后重启php5-fpm

sudo service php5-fpm restart

即可。参考文章:

 

After doing an upgrade on my Debian virtual server, which upgraded PHP and Nginx, I got a "502 Bad Gateway" error when browsing websites on that server. This post shows how to fix this problem, and the configuration option to prevent it occurring again on reboot. 

tl;dr

Edit /etc/php5/fpm/pool.d/www.conf and uncomment the following:

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

Then run:

    sudo service php5-fpm restart

Longer answer

As well as the error in the browser, I was getting this error in the Nginx error log: 

[crit] 2686#0: *1 connect() to unix:/var/run/php5-fpm.sock failed (13: Permission denied) while connecting to upstream, client: 192.168.50.1, server: [...], request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "[...]"

The problem is caused by the permissions and ownership of the /var/run/php5-fpm.sock file, which after I'd done the upgrade change to something like root:root and 0660, so it couldn't be accessed by the www-data user which Nginx was running as.

The immediate solution is to change the permissions and/or ownership of the file like so:

chmod 0666 /var/run/php5-fpm.sock

OR

chmod 0660 /var/run/php5-fpm.sockchown www-data:www-data /var/run/php5-fpm.sock

The only catch is this won't persist after the server is restarted. To prevent the issue from occurring again, edit the /etc/php5/fpm/pool.d/www.conf file:

sudo nano /etc/php5/fpm/pool.d/www.conf

Locate the following lines and uncomment them:

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

If you already changed the ownership/permissions of the socket file as shown above, then you don't need to do anything else now. If you didn't, then run this: 

sudo service php5-fpm restart

This re-creates the socket file with the ownership and permissions as configured in the file.

转载于:https://www.cnblogs.com/zl0372/p/nginx_140725.html

你可能感兴趣的文章
深度优先搜索-和为某数的所有组合
查看>>
linux下创建用户
查看>>
Docker镜像与容器命令
查看>>
jquerymobile iscrollview
查看>>
Java注释模板
查看>>
N002-认知C#中的字符串
查看>>
<org manual>翻译--3.6 Org-Plot
查看>>
Sublime Text 3 汉化
查看>>
mysql的权限管理
查看>>
JS引入其他文件
查看>>
leetcode解题报告:Interleaving String
查看>>
冲上云霄 之一 初识云
查看>>
Upgrade GI/CRS 11.1.0.7 to 11.2.0.2. Rootupgrade.sh Hanging
查看>>
数学之美番外篇:平凡而又神奇的贝叶斯方法
查看>>
UIcollectionView 加入尾部视图
查看>>
Minecraft InputFix
查看>>
集算器协助MongoDB计算之交叉汇总
查看>>
Nginx服务的ssl认证和htpasswd认证
查看>>
POJO中使用ThreadLocal实现Java嵌套事务
查看>>
nginx错误日志
查看>>