我在Debian Wheezy上有这个错误,我不明白我在想什么。 从php5-fpm的日志是确定的。
来自apache2日志的错误 :
[error] (2)No such file or directory: FastCGI: failed to connect to server "/var/lib/apache2/fastcgi/php5.fastcgi": connect() failed [error] FastCGI: incomplete headers (0 bytes) received from server "/var/lib/apache2/fastcgi/php5.fastcgi"
fastcgi.conf的内容:
<IfModule mod_fastcgi.c> AddHandler fastcgi-script .fcgi #FastCgiWrapper /usr/lib/apache2/suexec FastCgiIpcDir /var/lib/apache2/fastcgi </IfModule>
php5-fpm.conf的内容:
<IfModule mod_fastcgi.c> Alias /php5.fastcgi /var/lib/apache2/fastcgi/php5.fastcgi AddHandler php-script .php FastCGIExternalServer /var/lib/apache2/fastcgi/php5.fastcgi -socket /var/run/php5-fpm.sock -idle-timeout 610 Action php-script /php5.fastcgi virtual # Forbid access to the fastcgi handler. <Directory /var/lib/apache2/fastcgi> <Files php5.fastcgi> Order deny,allow Allow from all </Files> </Directory> # FPM status page. <Location /php-fpm-status> SetHandler php-script Order deny,allow Deny from all Allow from 127.0.0.1 ::1 </Location> # FPM ping page. <Location /php-fpm-ping> SetHandler php-script Order deny,allow Deny from all Allow from 127.0.0.1 ::1 </Location> </IfModule>
pool.d / www.conf的内容:
[www] listen = /var/run/www.sock ; Permission socket listen.owner = www listen.group = www ; Utilsateur/Groupe des processus user = www group = www ; gestion des processus pm = dynamic pm = dynamic pm.max_children = 500 pm.start_servers = 500 pm.min_spare_servers = 150 pm.max_spare_servers = 500 request_terminate_timeout = 605 ; Status pm.status_path = /php-fpm-status ping.path = /php-fpm-ping ; log access.log = /var/log/php/access.www.log access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%" ;Conf PHP php_admin_value[open_basedir]=/home/web/xxx/www/prod php_admin_value[session.save_path]=/home/web/xxx/www/tmp php_admin_value[upload_tmp_dir]=/home/web/xxx/www/tmp php_admin_value[error_log] = /var/log/php/error.www.log php_admin_flag[log_errors] = on php_admin_value[max_execution_time] = 0 php_admin_value[max_input_time] = 0 ; upload php_admin_value[upload_max_filesize] = 105M php_admin_value[post_max_size] = 105M
Apache VHost www :
<VirtualHost *:80> ServerName xxxx.com ServerAdmin [email protected] DocumentRoot /home/web/xxxx/www/prod Options None
快速CGI + FPM :
FastCgiExternalServer /home/web/xxxx/www/cgi-bin/php5.external -idle-timeout 310 -flush -socket /var/run/www.sock Alias /cgi-bin/ /home/web/xxxx/www/cgi-bin/ <Directory /home/web/xxxx/www/prod/> Options Indexes FollowSymLinks Includes AllowOverride None Order allow,deny Allow from all </Directory> ErrorLog /var/log/apache2/error.www_prod.log LogLevel debug CustomLog /var/log/apache2/access.www_prod combined </VirtualHost>
grep www / etc / passwd的输出:
www:x:1001:1001:,,,:/home/web/xxxx/www:/bin/bash
apache2ctl -t -D的输出DUMP_MODULES :
Loaded Modules: core_module (static) log_config_module (static) logio_module (static) version_module (static) mpm_worker_module (static) http_module (static) so_module (static) actions_module (shared) alias_module (shared) auth_basic_module (shared) authn_file_module (shared) authz_default_module (shared) authz_groupfile_module (shared) authz_host_module (shared) authz_user_module (shared) autoindex_module (shared) cgid_module (shared) deflate_module (shared) dir_module (shared) env_module (shared) fastcgi_module (shared) mime_module (shared) negotiation_module (shared) reqtimeout_module (shared) rewrite_module (shared) setenvif_module (shared) ssl_module (shared) status_module (shared) Syntax OK
我错过了什么?
在pool.d / http://www.conf中,注意
listen = /var/run/www.sock
在php5-fpm.conf中,在这一行:
FastCGIExternalServer /var/lib/apache2/fastcgi/php5.fastcgi -socket /var/run/php5-fpm.sock -idle-timeout 610
/var/run/php5-fpm.sock必须与pool.d / http://www.conf中的listen选项相同
在VHost www:
FastCgiExternalServer /home/web/xxxx/www/cgi-bin/php5.external -idle-timeout 310 -flush -socket /var/run/www.sock
这条线没有用处
Alias /php5.external /home/web/xxxx/www/cgi-bin/php5.external Action php-script /php5.external virtual
希望这个帮助。
你可以在这里阅读这个: http : //www.fastcgi.com/mod_fastcgi/docs/mod_fastcgi.html#FastCgiExternalServer
我假设你想运行每个虚拟主机作为一个不同的用户/组。 否则,只需要在conf文件中的任何地方使用它们(可以在fastcgi.conf中)。 为此,看看这个url:
对于以用户身份运行,我将尝试解释这是如何工作的:
我不认为你必须去触摸php-fpm.conf,只要保持它就像当你安装php5-fpm时没有评论我看起来像这样:
PHP-fpm.conf
[global] pid = /var/run/php5-fpm.pid error_log = /var/log/php5-fpm.log include=/etc/php5/fpm/pool.d/*.conf
你似乎有一个虚拟主机,所以我不知道你会用fastcgiexternalservers做什么。
php被挤压的步骤如下:
在#4,在#3给出的别名将由fastcgiexternalserverparsing(path不必存在),并且socket参数是相对于前面定义的FastCgiIpcDir的文件名。 我目前正在使用以下目录:
FastCgiIpcDir /var/run/
这将意味着你的旅程将继续在/etc/php5/fpm/pool.d/www.conf
重要的一行是:
listen = /var/run/php5-fpm.sock
path必须与fastcgiipcdir加上相对的套接字名称相同,因此stream程将在此处被拾取。 没有评论:
[www] user = www-data group = www-data listen = /var/run/php5-fpm.sock pm = dynamic pm.max_children = 5 pm.start_servers = 2 pm.min_spare_servers = 1 pm.max_spare_servers = 3 chdir = /
对于每个套接字(如果每个套接字是不同的,每个套接字)你想听,你必须创build新的conf文件(如www.conf)。 我之前描述的四个步骤应该位于每个虚拟主机中,您希望作为其他用户/组运行。 我相信它应该是这样的:
Vhost www
<VirtualHost *:80> ServerName xxxx.com ServerAdmin [email protected] DocumentRoot /home/web/xxxx/www/prod Options None AddHandler php-script .php Action php-script /php5.fastcgi Alias /php5.fastcgi /var/lib/apache2/fastcgi/php5.fastcgi FastCgiExternalServer /var/lib/apache2/fastcgi/php5.fastcgi -socket php5-fpm.sock <Directory /home/web/xxxx/www/prod/> Options Indexes FollowSymLinks Includes AllowOverride None Order allow,deny Allow from all </Directory> ErrorLog /var/log/apache2/error.www_prod.log LogLevel debug CustomLog /var/log/apache2/access.www_prod combined </VirtualHost>
在此之后,请确保在创build套接字的位置写入权限 。 这将是Ubuntu上的fastcgiipcdir / var / run,它指向/运行,所以我只是chmodded:
chmod 777 /run
(当然,这样做不是很好,但是对于演示和本地testing来说,这很好)
启用您的网站:
a2ensite site //site: just whatever your www vhost conf file name is
而当你想尝试一下, 总是重新启动php-fpm和apache :
service php5-fpm restart service apache2 restart
试着首先了解这些,然后使其工作将是小菜一碟。 我尝试了很多不同的组合,但是当我理解它的时候,这是有道理的。