PHP-FPM无法连接到FastCGI服务器

时间:2015-11-24 19:50:22

标签: php apache fastcgi

所以我第一次设置PHP5-FPM,起初一切顺利,我可以看到我的网站启动并运行,直到我做了一些调整

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

特别是在这些方面:

pm.max_children = 100 # The hard-limit total number of processes allowed
pm.start_servers = 20 # When nginx starts, have this many processes waiting for requests
pm.min_spare_servers = 10 # Number spare processes nginx will create
pm.max_spare_servers = 20 # Number spare processes attempted to create
pm.process_idle_timeout = 10s;

当我重新启动apache和php5-fpm服务时,我收到以下错误:

[Wed Nov 25 02:39:43.973654 2015] [fastcgi:error] [pid 5438] (2)No such file or directory: [client 36.72.129.207:60098] FastCGI: failed to connect to server "/usr/lib/cgi-bin/php5-fcgi": connect() failed
[Wed Nov 25 02:39:43.973705 2015] [fastcgi:error] [pid 5438] [client 36.72.129.207:60098] FastCGI: incomplete headers (0 bytes) received from server "/usr/lib/cgi-bin/php5-fcgi"

所以我认为这是因为我没有使用UNIX套接字连接,所以我再次检查了我的www.conf文件:

我可以验证:

listen = /var/run/php5-fpm.sock

我的php5-fpm.conf如下:

<IfModule mod_fastcgi.c>
AddHandler php5-fcgi .php
Action php5-fcgi /php5-fcgi
Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi
FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -socket /var/run/php5-fpm.sock -pass-header Authorization

<Directory /usr/lib/cgi-bin>
    Require all granted
</Directory>

</IfModule>

我的apache2.conf如下:

<IfModule fastcgi_module>
  # Add a new action that points to a virtual (non-existent) handler.
  # I will repeat, NON-EXISTENT. This is a virtual (non-existent) handler.
  #   i.e. `/fastcgi.php5-fpm` does not exist, that's OK :-)
  # The name of our handler is decided here. Let's call it `fastcgi-php5-fpm`.
  # See also <http://httpd.apache.org/docs/current/mod/mod_actions.html#action>

  Action fastcgi-php5-fpm /fastcgi.php5-fpm virtual

  # Now let's add an alias mapping that gives meaning to our virtual handler.
  # This forwards requests hitting our virtual (non-existent) handler;
  # sending them to FastCGI; which is yet another virtual handler.
  # I repeat, NON-EXISTENT. This is a virtual handler that does not exist.
  #   i.e. `/var/www/cgi-bin/fastcgi.php5-fpm` does not exist, that's OK :-)
  # See also <http://httpd.apache.org/docs/current/mod/mod_alias.html#alias>

  Alias /fastcgi.php5-fpm /var/www/cgi-bin/fastcgi.php5-fpm

  # Now, let's setup FastCGI so it works w/ our virtual handler and PHP5-FPM.
  # See also <http://www.fastcgi.com/mod_fastcgi/docs/mod_fastcgi.html#FastCgiExternalServer>

  FastCgiExternalServer /var/www/cgi-bin/fastcgi.php5-fpm -socket /var/run/php5-fpm.sock -idle-timeout 900 -pass-header Authorization -pass-he$

  # Associate our handler with PHP files; including PHAR files.

  AddHandler fastcgi-php5-fpm php phar
</IfModule>

我仍然不明白为什么突然我的Apache给了我500个错误,说它在5分钟前无法连接,它确实......

任何人都可以帮助我...

0 个答案:

没有答案