3

I have installed Apache php7.0 and mysql on an Ubuntu 16.04 machine and I get the answer "php is not running." Here is my vhost configuration:

<VirtualHost *:80>
  ServerAdmin webmaster@example.com
  ServerName www.example.com
  DocumentRoot /var/www/sites/www.example.com/httpdocs
  ScriptAlias "cgi-bin" "/var/www/sites/wwww.example.com/cgi-bin"

  ErrorLog ${APACHE_LOG_DIR}/www.example.com.error_log

  LogLevel debug

  CustomLog ${APACHE_LOG_DIR}/www.example.com.log combined

    <IfModule mod_fastcgi.c>

    AddHandler php7-fcgi .php
    Action php7-fcgi /php7-fcgi virtual
    Alias /php7-fcgi-kermit /usr/lib/cgi-bin/php7-fcgi-kermit
    FastCgiExternalServer /usr/lib/cgi-bin/php7-fcgi-kermit -socket /run/php/php7.0-fpm.kermit.sock -pass-header Authorization

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

  <IfModule mod_fastcgi.c>
    <FilesMatch ".+\.ph(p[345]?|t|tml)$">
      SetHandler php7-fcgi-kermit
    </FilesMatch>
  </IfModule>

</VirtualHost>

When I try to go to the site it is not parsing the php but printing it to the screen.

Does anybody have any ideas?

I have gotten rid of all of the other fpm stuff that used to work with apache 2.2 and have added this line to the conf

ProxyPassMatch ^/(.*\.php(/.*)?)$ unix:/var/run/php/php7.0-fpm.kermit.sock|fcgi://localhost/var/www/sites/www.example.com/httpdocs  

Now I get the following error in the error logs

[Wed Mar 21 13:04:35.539499 2018] [proxy:error] [pid 26569] (13)Permission denied: AH02454: FCGI: attempt to connect to Unix domain socket /var/run/php/php7.0-fpm.kermit.sock (localhost) failed

The permisssions look correct for the socket

srw-rw----  1 kermit   kermit     0 Mar 21 13:00 php7.0-fpm.kermit.sock=  

I do not know where it is getting that = sign though

3 Answers3

2

If you are using PHP-FPM, you should consider using mod_proxy_fcgi, which is newly available in Apache 2.4 and is just for this type of use case. The Apache wiki entry for PHP-FPM has some good guidance to get started.

The mod_proxy_fcgi documentation also includes specific examples for setting up PHP-FPM and the PHP documentation also has helpful information.

Colt
  • 2,127
0

Your socket permissions are incorrect: "srw-rw---- 1 kermit kermit 0 Mar 21 13:00 php7.0-fpm.kermit.sock"

You say Apache runs with www-data.

You either need to add www-data to kermit or change the socket permissions in php-fpm pool config to something like kermit:www-data

0

I was able to fix this by changing the group to www-data along with a couple of other changes that occurred in later versions of apache-22 and 24