我安装了apache2.4和php-fpm,但我仍然有php5-cgi处理我的请求,虽然php-fpm进程正在运行。
这是我做的:
apt-get install php5-fpm
apt-get install libapache2-mod-fastcgi
a2enmod actions
像这样编辑/etc/apache2/mods-available/fastcgi.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>
service apache2 restart
但现在如果我运行phpinfo(),我得到:
Server API CGI/FastCGI
而不是FPM / FastCGI
答案 0 :(得分:1)
好的,我终于找到了为什么php fpm没有被使用: 我需要在我的vhost文件中启用它。编辑:
/etc/apache2/sites-enabled/domain.conf
删除:
AddType application/x-httpd-php .php
AddHandler fcgid-script .php
AddHandler fcgid-script .php5
FCGIWrapper /home/domain/fcgi-bin/php5.fcgi .php
添加:
ProxyPassMatch ^/(.*.php(/.*)?)$ unix:/var/run/php5-fpm.sock|fcgi://localhost/home/domain/domains/domain/public_html/$1
答案 1 :(得分:0)
另一次尝试:
安装Apache Worker MPM(多处理模块)
sudo apt-get install apache2-mpm-worker
sudo apt-get install libapache2-mod-fastcgi php5-fpm php5
sudo apt-get update
再次:
sudo apt-get install libapache2-mod-fastcgi php5-fpm php5
sudo a2enmod actions fastcgi alias
重启apache
sudo service apache2 restart
然后sudo nano /etc/apache2/conf.d/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 -host 127.0.0.1:9000 -pass-header Authorization
<Directory /usr/lib/cgi-bin>
Require all granted
</Directory>
#directory statement mult be on multiple lines
</IfModule>
然后:
sudo service apache2 restart
这应该有用