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?
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?
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