How to configure Apache for Multiple PHP version from htaccess
Asked Answered
C

1

1

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:

php54.test
php55.test
php56.test
php70.test
php71.test

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 libphpX.so for loading them as modules:

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

    #SOMETHING LIKE THIS... 
    LoadModule php??_module       modules/libphp??.so

</VirtualHost>

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.

Compelling answered 15/10, 2016 at 0:27 Comment(0)
A
5

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://127.0.0.1:9070"

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.

Austinaustina answered 15/10, 2016 at 6:54 Comment(1)
The solution presented by @Remi Collet in his article works like a charm!Compelling

© 2022 - 2024 — McMap. All rights reserved.