Link to home
Start Free TrialLog in
Avatar of tonelm54
tonelm54

asked on

Install multiple versions of PHP but specify in host config

Ive usually installed PHP via:-
sudo apt install php libapache2-mod-php php-mysql

Open in new window

Which works great and installs the latest version of PHP and configures everything fine :-)

Problem is I want some of my sites to run on PHP 5 (for historical purposes), some to run on the current version of PHP 7 and some to run on a future version of PHP 7 for testing.

On my hosting website, I can add a line into the vhost configuration to tell it what version of PHP to run, for example to run PHP7 I just add this into the htaccess file and it runs the site with PHP 7:-
AddType application/x-httpd-php70 .php
This is exactly what I want to do, however all the guides Ive found online talk about running everything under the same version, but not individual sites.

Anyone got any ideas on this?

Ideally I want to download different versions of PHP into a folder \PHP\PHP7.3\ and then inside htaccess point to use \PHP\PHP7.3\ or something different.

Im using Ubuntu server with Apache if that helps, and this is only for development purposes, not production.
Avatar of kenfcamp
kenfcamp
Flag of United States of America image

You're not going to be able to do this on the same server
Avatar of Kimputer
Kimputer

In the main configuration, add these:


<Directory "/www/htdocs/site1">
AddType application/x-httpd-php70 .php
</Directory>


<Directory "/www/htdocs/site2">
AddType application/x-httpd-php5 .php
</Directory>

   

ASKER CERTIFIED SOLUTION
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

Gentoo allows installing multiple version of the php server by default. Still running multiple on one webserver can be challenge.


Probably switching to php-fpm is an option (fastcgi php) then you can run several instances ( different config or versions ) 

and map certain paths to certain fpm backends.  which is considerable simpler to maintain and manage.

(It also allows for setups like for only one of the paths on your site you need humoungous amount of memory for buffering) then you can use a setup with limited number of backends for that one wile the others have multiple instances running.