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 [email protected] 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
  • What user is httpd running on? Commented Mar 21, 2018 at 18:46
  • Right now it is running as www-data but there will be several users for php-fpm so what do I need to do to make it run correctly under fpm Commented Mar 21, 2018 at 20:54
  • If apache runs on www-data is www-data inside group kermit? or how do you expect it to submit requests to that socket? Commented Mar 22, 2018 at 17:20

3 Answers 3

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.

9
  • I've been staring at that apache wiki document for some time now and it's fairly high level. Can you suggest anything with step-by-step instructions for Ubuntu? I'm confused as to why this is so complicated. Commented Mar 22, 2018 at 17:32
  • @S.Imp I think the wiki is best read together with the referenced mod_proxy_fcgi documentation. It is really pretty straight forward: (1) use the correct modules, and (2) set up the desired ProxyPassMatch - either TCP socket approach or UDS approach Commented Mar 22, 2018 at 22:17
  • @S.Imp In any case, you should just start working through a set up, and if you run into problems come back with a new question of your own detailing what you have done, what errors you receive, how you have attempted to solve them, etc. I don't think it is appropriate to extend this answer any further as the OP is clearly interested in resolving the mod_fastcgi approach for PHP-FPM, and is getting help from a very knowledgeable HTTPD guy. Commented Mar 22, 2018 at 22:24
  • I have in fact done so here. It seems to be working but I'm not sure if the instructions I've captured are exactly correct. Surprising to me that Ubuntu doesn't offer an apt package to set this up. Commented Mar 22, 2018 at 22:35
  • @S.Imp Why would there be an apt package for this? They are just Apache modules and directives and php configurations. Commented Mar 22, 2018 at 22:40
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

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.