这里选择直接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-data
listen.group = www-data
listen.mode =

然后重启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.sock
chown 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-data
listen.group = www-data
listen.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.

php fpm安装curl后,nginx出现connect() to unix:/var/run/php5-fpm.sock failed (13: Permission denied)的错误的更多相关文章

  1. nginx 502错 failed (13: Permission denied)

    安装nginx和php-fpm之后出现502错误 找了个理由说php-fpm不启动 ,但在我的实践中,该过程开始 找了半天没找到病因.视图nginx记录后 我发现下面的错误 [crit] 2686#0 ...

  2. 解决Nginx的connect() to 127.0.0.1:8080 failed (13: Permission denied) while connect

    在进行Nginx+Tomcat 负载均衡的时候遇到了这个权限问题,在error.log日志中.我们能够看到例如以下: connect() to 127.0.0.1:8080 failed (13: P ...

  3. 解决nginx访问问题connect() to 127.0.0.1:8080 failed (13: Permission denied) while connecting to upstream,

    问题:搭建好项目之后,用nginx进行代理,进行日常配置之后,发现前端正常访问,但是后端访问出现错误,报502错误,查找nginx日志,发现connect() to 127.0.0.1:8080 fa ...

  4. 转connect() to unix:/var/run/php-fpm.sock failed (11: Resource temporarily unavailable)

    网站常出现502 bad gateway,程序没有问题. 根据nginx日志:connect() to unix:/var/run/php-fpm.sock failed (11: Resource ...

  5. connect() to unix:/var/run/php-fpm.sock failed (11: Resource temporarily unavailable)

    nginx + php做服务,在高并发的时候会出现一些错误  connect() to unix:/var/run/php-fpm.sock failed (11: Resource temporar ...

  6. Ubuntu nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied)

    在Ubuntu 12中启动刚安装好的Nginx,报错: nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied) 原因如下: ...

  7. nginx权限问题failed(13:Permission denied)

    nginx权限问题failed(13:Permission denied) 环境配置  nginx Permission denied 问题: 使用nginx代理uwsgi,出现500错误,查看ngi ...

  8. 解决Mac nginx问题 [emerg] 54933#0: bind() to 0.0.0.0:80 failed (13: Permission denied)

    brew services restart nginx Stopping nginx... (might take a while) ==> Successfully stopped nginx ...

  9. nginx: [emerg] open() "/var/run/nginx.pid" failed (13: Permission denied)

    现象 1.centos6.9 用rpm包安装nginx 2.修改Nginx的多个配置文件和配置项 3.service nginx restart 报错: nginx: [emerg] open() & ...

随机推荐

  1. bzoj 2137: submultiple

                                                     Time Limit: 10 Sec  Memory Limit: 259 MB Submit: 23 ...

  2. 【模拟】 Codeforces Round #434 (Div. 1, based on Technocup 2018 Elimination Round 1) C. Tests Renumeration

    题意:有一堆数据,某些是样例数据(假设X个),某些是大数据(假设Y个),但这些数据文件的命名非常混乱.要你给它们一个一个地重命名,保证任意时刻没有重名文件的前提之下,使得样例数据命名为1~X,大数据命 ...

  3. 企鹅----sap+裂点

    企鹅 题目描述 在靠近南极的某处,一些企鹅站在许多漂浮的冰块上.由于企鹅是群居动物,所以它们想要聚集到一起,在同一个冰块上.企鹅们不想把自己的身体弄湿,所以它们在冰块之间跳跃,但是它们的跳跃距离,有一 ...

  4. 零起点学算法08——简单的输入和计算(a+b)

    #include <stdio.h> int main() { int a; int b; scanf("%d %d",&a,&b); printf(& ...

  5. 关于JS的This指针

    下面讨论一个执行上下文的最后一个属性——this指针的概念. This指针 A this value is a special object which is related with the exe ...

  6. 简单理解SNAT回流中的概念:路由器怎么知道外网返回的数据是局域网中哪台主机的

    内网到外网用的是NAT技术(地址封装)外网到内网用的是端口映射(PNAT)计算机的端口又65535(0-65534),你说的那些有名气的端口大多都是0-1023之间的你说的这个问题很简单,但首先你要懂 ...

  7. Cloud Foundry中vmc tunnel与caldecott原理

    在Cloud Foundry中,用户可以vmc create-service创建一个service instance,但是常规情况下,用户不能手动地进一步对service instance进行设计.以 ...

  8. 在Visual Studio中开发Matlab mex文件,生成mexw64/mexw32

    csunking贡献,2015-9-22 1712 1.   概述 通过使用C/C++与Matlab混合编程,既可以享受到C代码快速执行的速度,又可以方便的使用Matlab众多的库函数和强大的绘图功能 ...

  9. 调用wsdl的接口-用axis

    // 创建一个服务(service)调用(call) org.apache.axis.client.Service service = new org.apache.axis.client.Servi ...

  10. 解决新浪微博API调用限制 突破rate_limit_status瓶颈

    新浪微博开放平台API的调用和TWITTER接口一样,都是受限的,以小时为单位进行限定. 他有两个限制原则 1.用户不登录基于IP的限制,每小时1000次 2.用户登录了基于用户的限制,每小时1000 ...