在ubuntu12.04中安装配置LNMP时 出现在php5-fpm的错误
1 2 3 4 5 6 7 8 | 2013/04/26 04:01:05 [crit] 6119#0: *4 connect() to unix:/var/run/php5-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 159.53.110.141, server: 216.238.88.42, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "216.238.88.42:9090 |
nginx中是这样配置的
1 2 3 4 5 6 7 8 9 10 11 | location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini # With php5-cgi alone: fastcgi_pass 127.0.0.1:9000; # With php5-fpm: fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; } |
我个人的配置是想用sock的方法 毕竟sock方式对于高并发来说 还是比使用cgi方式好的
问题其实出现在 fastcgi_pass得配置上面。在ubuntu 12.10安装了php5-fpm之后。我们可以去
1 | /etc/php5/fpm/pool.d/www.conf |
里面找到这样一段代码:
1 | listen = 127.0.0.1:9000 |
在这上面代码的下面添加一行:
1 | listen = /var/run/php5-fpm.sock |
保存后启动php5-fpm
1 | /etc/init.d/php5-fpm restart |
这时就可以正常访问了
另外有可能是sock文件的执行权限有问题,对sock文件执行
1 | chmod 777 php5-fpm.sock |
再启动php5-fpm问题解决。