StigM
StigM

Reputation: 711

How to run single PHP5-FPM on nginx and Apache2 at once

I have a requirement for a testing server which can run some sites using Nginx and some sites using Apache2 (with .htaccess files for example).

Is it possible to use a single PHP5-FPM pool (with the same PHP.ini) for both Nginx and Apache2 both running at once?

Upvotes: 2

Views: 152

Answers (1)

StigM
StigM

Reputation: 711

Didn't get an answer, but I was able to confirm this works fine and both Apache and Nginx can use the same pool at the same time.

Setting up Apache2 to use php5-fpm (as suggested by Mohammad AbuShady) with these instructions, then installing nginx and adding relevant 'fastcgi_pass' parameters.

Example apache2 config:

<IfModule mod_fastcgi.c>
  FastCgiIpcDir /var/lib/apache2/fastcgi
  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
</IfModule>

Example nginx config:

    location ~ \.php$ {
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_read_timeout 120;
    }

Example php5-fpm config:

listen = 127.0.0.1:9000

Also, don't forget you will need to bind Apache2 and Nginx to different ports or different IP addresses.

Upvotes: 2

Related Questions