0

I need to have PHP 5 and 7 working concurrently because of the need to use two PHP extensions that are only built for exclusively versions 5 and 7.

I've got this working with Nginx by naming the pages that call on the PHP 5 extension to e.g. page.php5, and having location blocks as follows:

location ~ \.php5$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
}

location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}

Works fine. But how to do the same with Apache? I've read about having different virtual hosts, one using a PHP module and one using fast-cgi, but ideally I'd rather have something much closer to the location method above and have just the one host.

Can this be done?

Thanks.

whoasked
  • 269
  • 5
  • 12

1 Answers1

1

Check the manual for mod_proxy_fcgi for the correct syntax to pass needed options but the equivalent would roughly be to use a ProxyPassMatch:

ProxyPassMatch ^/(.*\.php5(/.*)?)$ unix:/var/run/php5-fpm.sock;
ProxyPassMatch ^/(.*\.php(/.*)?)$  unix:/var/run/php/php7.0-fpm.sock;
HBruijn
  • 77,029
  • 24
  • 135
  • 201
  • Ok thanks. It doesn't seem there's a sanctioned Apache release for my distro that supports unix sockets for ProxyPassMatch yet, but I'll return to it at a later date (getting this working on Apache isn't urgent). – whoasked Aug 01 '16 at 13:50