I have upgraded, built a new one, my server (Ubuntu 18.04.6) which is running PHP Version 7.2.

I would like to install PHP5 and keep PHP7 and have the option to switch back and forth. Have a site that runs php5 that I only need up for a short time, plus do some code upgrade on other projects...

I have found instructions:

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update


sudo apt-get install -y php5.6


sudo apt-get install php5.6 php5.6-mysql php5.6-gd php5.6-mcrypt php5.6-mbstring php5.6-sqlite3 libapache2-mod-php5.6

But it is usually followed up by intalling php7. I do not want to overwrite the php I already have...

Also, I do use webmin, and notice in the module page I can activate php7. I figured it would install a module (php5) that I can activate and deactivate.


  • Consider using PHP-FPM which gives you the ability to choose PHP version per pool i.e. per site. – Esa Jokinen Jun 29 '20 at 22:46
  • Got it to work with the data for installing php5.6 and switched apache to use the php5.6 module. Had to install other dependencies the site needed (phpCURL, etc...) Will look into PHO-FPM – tpage Jul 8 '20 at 13:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.