Gilberto Albino Gilberto Albino - 1 year ago 190
Apache Configuration Question

How to configure Apache for Multiple PHP version from htaccess

I have installed a collection of PHP versions from Remi Repositories, which may be ignored, for the question itself, but kept for the sake of understanding the processed I tried.

They work fine from command line, but I'd like to use them with Apache 2 (httpd on Fedora 24), running multiple virtual hosts as in:


I have created the VirtualHost conf files and each one is working fine.

I want to run each corresponding php version (accordingly to the suggestive ServerName), but I can't find how to load PHP from each Virtual Host.
I couldn't find the corresponding Remi for loading them as modules:

<VirtualHost *:80>
ServerName php54.test
DocumentRoot /var/www/php54

LoadModule php??_module modules/libphp??.so


I have, and this is not news, a shared hosting that allows me to change PHP version from .htaccess and I can do something like this:

AddHandler application/x-httpd-php54 .php
AddHandler application/x-httpd-php55 .php
AddHandler application/x-httpd-php56 .php
AddHandler application/x-httpd-php7 .php
AddHandler application/x-httpd-php71 .php

I may look like a dummy now, but how can I do the same .htaccess switching for having multiple PHP versions available?

I probably am not knowing what and how to search on Google to find the best matched answer.

Answer Source

You cannot use multiple versions of mod_php.

Better solution is to use php-fpm (the Fastcgi Process Manager), using in each vhost a SetHandler to fcgi server:

    SetHandler "proxy:fcgi://"

Or (using unix domain socket)

    SetHandler "proxy:unix:/var/opt/remi/php70/run/php-fpm/www.sock|fcgi://localhost"

This is described in this article : My PHP workstation.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download