这里选择直接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. 【插头dp】CDOJ1690 这是一道比CCCC简单题难的简单题

    最裸的插头dp,可参见大白书. #include<cstdio> #include<cstring> using namespace std; #define MOD 1000 ...

  2. SOCKET类型定义及应用

    读代码时看到此处,摘记下来. 流套接字(SOCK_STREAM):流套接字用于提供面向连接.可靠的数据传输服务.该服务将保证数据能够实现无差错.无重复发送,并按顺序接收.流套接字之所以能够实现可靠的数 ...

  3. 20162307 实验三 敏捷开发与XP实践

    实验三 <敏捷开发与XP实践> 北京电子科技学院(BESTI) 实 验 报 告 课程:程序设计与数据结构 班级:1623 姓名:张韵琪 学号:20162307 指导教师:娄佳鹏老师.王志强 ...

  4. 【MySQL笔记】触发器,存储过程和函数

    一.触发器 触发器(TRIGGER):是由事件来触发某个操作.当数据库系统执行这些事件时,就会激活触发器执行相应的操作.MySQL从5.0.2版本开始支持触发器. 触发事件:INSERT语句.UPDA ...

  5. Java高级架构师(一)第31节:Nginx简介、安装和基本运行

    第一节:主要介绍Nginx和安装

  6. zk选举过程

    1. 服务器启动时期的Leader选举 若进行Leader选举,则至少需要两台机器,这里选取3台机器组成的服务器集群为例.在集群初始化阶段,当有一台服务器Server1启动时,其单独无法进行和完成Le ...

  7. Linq 时间参数的一个坑

    背景:查询某个字段大于系统时间的数据 两种写法: 1.DataTime now=DateTime.Now; var result=dbContext.Table1.Created>now 2.  ...

  8. android非法字符的判定、表情符号的判定

    public class EmojiEditText extends EditText {// 输入表情前的光标位置private int cursorPos; // 输入表情前EditText中的文 ...

  9. java中copy 一个list集合的方法

    java将一个list里的数据转移到另外一个list,可以使用for语句,一次使用add方法,示例如下: ArrayList list1=new ArrayList(); list1.add(&quo ...

  10. 流畅的python第九章符合Python风格的对象学习记录

    对象表示形式 每门面向对象的语言至少都有一种获取对象的字符串表示形式的标准方式.Python提供了两种方式 repr()便于开发者理解的方式返回对象的字符串表示形式 str()便于用户理解的方式返回对 ...