You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Jason Brooks <ja...@eroi.com> on 2016/11/03 18:05:00 UTC

[users@httpd] Question about configuring apache to use php via fpm

Hello,

There are several sites on configuring apache with php-fpm.  Many don’t work, some appear to be contradictory.  

Thus far, I found two configurations that work, but I am not sure which one is more correct.  By “more correct” I mean 

less convoluted
less hidden issues
less security problems
better performing
…

This is on a ubuntu 16.04 LTS server, running apache 2.4.18, mpm-event, with php7.0-fpm installed.  I do NOT have mod_php installed.  For my test, I am just running the phpinfo() function call.

Here are the configuration methods I have found to work:
----------------------------------------------------------------------------
1) using mod_alias, mod_fastcgi, and mod_actions:
	<Directory /usr/lib/cgi-bin> 
		Require all granted 
	 </Directory> 
	 <IfModule mod_fastcgi.c> 
		AddHandler php7-fcgi .php 
		Action php7-fcgi /php7-fcgi virtual 
		Alias /php7-fcgi /usr/lib/cgi-bin/php7-fcgi 
		FastCgiExternalServer /usr/lib/cgi-bin/php7-fcgi -host 127.0.0.1:9000 -pass-header Authorization 
	</IfModule>

This was found at https://www.howtoforge.com/tutorial/apache-with-php-fpm-on-ubuntu-16-04/ <https://www.howtoforge.com/tutorial/apache-with-php-fpm-on-ubuntu-16-04/> dated last August.
	it seems hacky: it needs a cgi-bin directory to be configured, but doesn’t actually put anything in a cgi-bin directory to execute...

----------------------------------------------------------------------------
2) using mod_proxy, and mod_proxy_fcgi
	ProxyPassMatch ^/(.*\.php(/.*)?)$ "fcgi://localhost:9000/var/www/html/$1" enablereuse=on

This was found at https://wiki.apache.org/httpd/PHP-FPM <https://wiki.apache.org/httpd/PHP-FPM> dated last July.
	it seems more elegant, but I don’t know how speedy it might be.

Thank you for your time!

—jason



Jason Brooks	Systems Administrator
eROI	Performance is Art.
 
m:	505 nw couch #300	w:	eroi.com <http://eroi.com/>
t:	503.290.3105	f:	503.228.4249


fb:	fb.com/eROI <http://www.facebook.com/eROI>









Re: [users@httpd] Question about configuring apache to use php via fpm

Posted by "Rose, John B" <jb...@utk.edu>.
You may also want to be aware of …

ProxyErrorOverride

In case you want to use Custom error pages from Apache when using php-fpm

From: Jason Brooks <ja...@eroi.com>
Reply-To: "users@httpd.apache.org" <us...@httpd.apache.org>
Date: Thursday, November 3, 2016 at 3:07 PM
To: "users@httpd.apache.org" <us...@httpd.apache.org>
Subject: Re: [users@httpd] Question about configuring apache to use php via fpm

This does help, thank you!

Jason Brooks

Systems Administrator

eROI

Performance is Art.




m:

505 nw couch #300

w:

eroi.com<http://eroi.com/>

t:

503.290.3105

f:

503.228.4249


fb:

fb.com/eROI<http://www.facebook.com/eROI>






On Nov 3, 2016, at 11:30 AM, Luca Toscano <to...@gmail.com>> wrote:

Hello Jason,

<snip>


mod-proxy-fcgi is the only one actively supported and developed in the httpd project at the moment, it is definitely the best choice for the php-fpm use case (standalone daemon that does not need more than a proxy in front of it).

https://httpd.apache.org/docs/2.4/mod/mod_proxy_fcgi.html#examples contains also good references.

Hope that helps!

Luca


Re: [users@httpd] Question about configuring apache to use php via fpm

Posted by Jason Brooks <ja...@eroi.com>.
This does help, thank you!

Jason Brooks	Systems Administrator
eROI	Performance is Art.
 
m:	505 nw couch #300	w:	eroi.com <http://eroi.com/>
t:	503.290.3105	f:	503.228.4249


fb:	fb.com/eROI <http://www.facebook.com/eROI>








> On Nov 3, 2016, at 11:30 AM, Luca Toscano <to...@gmail.com> wrote:
> 
> Hello Jason,
> 
> <snip>

> mod-proxy-fcgi is the only one actively supported and developed in the httpd project at the moment, it is definitely the best choice for the php-fpm use case (standalone daemon that does not need more than a proxy in front of it).
> 
> https://httpd.apache.org/docs/2.4/mod/mod_proxy_fcgi.html#examples <https://httpd.apache.org/docs/2.4/mod/mod_proxy_fcgi.html#examples> contains also good references.
> 
> Hope that helps!
> 
> Luca 


Re: [users@httpd] Question about configuring apache to use php via fpm

Posted by Luca Toscano <to...@gmail.com>.
Hello Jason,

2016-11-03 19:05 GMT+01:00 Jason Brooks <ja...@eroi.com>:

> Hello,
>
> There are several sites on configuring apache with php-fpm.  Many don’t
> work, some appear to be contradictory.
>
> Thus far, I found two configurations that work, but I am not sure which
> one is more correct.  By “more correct” I mean
>
> less convoluted
> less hidden issues
> less security problems
> better performing
> …
>
> This is on a ubuntu 16.04 LTS server, running apache 2.4.18, mpm-event,
> with php7.0-fpm installed.  I do NOT have mod_php installed.  For my test,
> I am just running the phpinfo() function call.
>
> Here are the configuration methods I have found to work:
> ------------------------------------------------------------
> ----------------
> 1) using mod_alias, mod_fastcgi, and mod_actions:
> <Directory /usr/lib/cgi-bin>
> Require all granted
>  </Directory>
>  <IfModule mod_fastcgi.c>
> AddHandler php7-fcgi .php
> Action php7-fcgi /php7-fcgi virtual
> Alias /php7-fcgi /usr/lib/cgi-bin/php7-fcgi
> FastCgiExternalServer /usr/lib/cgi-bin/php7-fcgi -host 127.0.0.1:9000
> -pass-header Authorization
> </IfModule>
>
> This was found at https://www.howtoforge.com/tutorial/apache-with-php-fpm-
> on-ubuntu-16-04/ dated last August.
> it seems hacky: it needs a cgi-bin directory to be configured, but doesn’t
> actually put anything in a cgi-bin directory to execute...
>
> ------------------------------------------------------------
> ----------------
> 2) using mod_proxy, and mod_proxy_fcgi
> ProxyPassMatch ^/(.*\.php(/.*)?)$ "fcgi://localhost:9000/var/www/html/$1"
> enablereuse=on
>
> This was found at https://wiki.apache.org/httpd/PHP-FPM dated last July.
> it seems more elegant, but I don’t know how speedy it might be.
>
>
mod-proxy-fcgi is the only one actively supported and developed in the
httpd project at the moment, it is definitely the best choice for the
php-fpm use case (standalone daemon that does not need more than a proxy in
front of it).

https://httpd.apache.org/docs/2.4/mod/mod_proxy_fcgi.html#examples contains
also good references.

Hope that helps!

Luca