I want to have both PHP 5.2.17 and PHP 5.3.5 installed on my Ubuntu machine and switch as per my necessity. How can I achieve this?
|
You can use a php version manager to achieve this. Different version managers are available like:
My favorite is phpbrew. Hope this helps. |
|||||||||||||||||||||
|
|
You can run 2 different PHP versions at once, but it's not as easy as just apt-getting them. You need to run one seperately installed version and serve it up according to the settings in your apache config. You can do this using fastcgi for example: basically what you are looking for is the config you see on this page. You add a different handler in your config based on the situation/port/domain you need. The trick, after installing both versions, is this step: ===from that page==
default:
php5.3.17:
php5.4.7:
See for the complete installation the linked question. Don't forget to look at the two links in the header as well, they look like nice tutorials (but less compressed). This and That (don't be put of by the fact that the linked question is a big one with no accepted answer. The method should (and does) work fine, but the user forgot to use |
||||
|
|
|
I installed php 5.6 and 7.0 but besides all tips it kept running 5.6, so this command saves the day (in my case i chosse option 1 and restart apache):
|
|||
|
|
|
This one works for me: https://lornajane.net/posts/2016/php-7-0-and-5-6-on-ubuntu Same as the script from "Growling Flea", but using new versions.
|
||||
|
|
|
From this post, I just put in order the commands and explain in order as I was served (Ubuntu 12.04) This method give you:
Install all versions that you need (i have two) Install dependencies:
Install PHP 5.3 first time. Download php sources
Install PHP5.6 first time. Download php sources
Script manager versions PHP: Create a file called
Compile and install php 5.3:
Compile and install php 5.6
Let's to use them:
|
||||
|
|
|
Problems:
Solution:
|
|||||||||
|
|
If you want to run them at the same time, you need two different ports. Maybe you can just change your apache config (httpd.conf) with a simple script that moves one or another version into the correct position before starting apache. |
|||||
|
|
You can also run each website with diferentes users. More secure. I used this aproach one time. http://blog.servergrove.com/2011/08/22/how-to-setup-multiple-php-versions-on-apache/ Now i think it is better to use php-fpm... but it is a litle more complicated to configure multiple php versions. Will need to run multiples php-fpms and set apache to use each other. |
|||||||||
|
|
I wrote a bash script that allows me to easily switch between installed php versions on my box. I run several virtual hosts because I have several web projects with customers that have old and new programs. Some of these projects require older versions of php and other projects require php7.0. Read through my comments and make sure you understand what is going on before using this.
|
||||
|
|
.phpand.php5files. You can also configure your WWW server to use different PHP versions for different ports (likehttp://localhost:80andhttp://localhost:8080) or different domains (likehttp://localphp52andhttp://localphp53) leaving all the remaining structure of folders intact so you can easily compare running one web application in two environments by changing the current URL. – cprn Feb 3 '13 at 1:10