Install php5 alongside with php7
I know this post has been here for a long time but I would answer anyway.
You can install php5
alongside.
All you need to do is install php5
.
After installing it, you would have multiple folders holding the different version of your php version.
First start by adding Ondřej Surý PPA to install different versions of PHP – PHP 5.6, PHP 7.0 and PHP 7.1 on Ubuntu system.
sudo apt install python-software-properties sudo add-apt-repository ppa:ondrej/php ##For Apache Web Server sudo apt install php5.6
Now you can install most required PHP modules from the list.
Install PHP Modules
sudo apt install php5.6-cli php5.6-xml php5.6-mysql
To switch between the versions
First make sure you stop your apache2 service
sudo service apache2 stop sudo a2dismod php7
I would suggest you run
phpinfo()
after the above steps to confirm the version running on your computer, if all went well, you should most likely get an error, as no php file would run.Enable e.g.
php5.6
sudo a2enmod php5.6
Restart your apache2 service
sudo service apache2 start
check php version
php -v
Related videos on Youtube
Comments
-
Run almost 2 years
I am on php7 now but I have a legacy program relies on php5 as it is using mysql instead of mysqli.
Can I have php5 installed alongside with php7 and switch them around when either of them is needed?
-
Steve R. about 7 yearsWhat about updating your program? Obviously that depends on the complexity of your program. I was able to update mine in a relatively short period of time, but then my program is very simple.
-
Run about 7 years@SteveR. im trying to now. It is modx - can't believe this program is worse than wordpress!
-
Steve R. about 7 yearsYou may want to look here: "PHP 7.0 (and 5.6) on Ubuntu" lornajane.net/posts/2016/php-7-0-and-5-6-on-ubuntu Since I do not have this dual configuration, I have no knowledge of how good the advice is.
-