How To Install Multiple PHP Version on Ubuntu 18.04 LTS

Install Multiple PHP Version on Ubuntu 18.04 LTS

In this tutorial, we will show you how to install Multiple PHP Version on Ubuntu 18.04 LTS. For those of you who didn’t know, PHP (recursive acronym for PHP: Hypertext Preprocessor) is an open-source, popular general-purpose scripting language that is widely-used and best suited for developing websites and web-based applications. It is a server-side scripting language that can be embedded in HTML.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo’ to the commands to get root privileges. I will show you through the step by step installation of Multiple PHP Version a Ubuntu 18.04 (Bionic Beaver) server.

Install Multiple PHP Version on Ubuntu 18.04 LTS Bionic Beaver

Step 1. First, make sure that all your system packages are up-to-date by running these following apt-get commands in the terminal.

Step 2. Installing PHP.

First, add the PPA to your system:

For this tutorial, we are using PHP 5.6 and PHP 7.2 to configure with Apache webserver. To use the multiple PHP versions, we will use PHP FPM:

After installation, check status PHP services are running:

Step 3. Apache Web Server Configuration.

First, create two directories on your server:

Next, create a test file named info.php with the content below. Save the file, then browse to it to see if PHP is working:

Let’s start the creation of VirtualHost and edit in your favorite text editor:

Add the following content:

Then, create a second VirtualHost configuration file to work with PHP 7.2:

Add the following content:

Create a symbolic link of config files to this directory or use the below command:

After making all the changes restart Apache to reload new settings changes:

Step 4. Test Multiple PHP Version.

Try to access it at shows the version PHP 5.6 and is showing PHP 7.2. If the PHP info page is rendered in your browser then everything looks good and you are ready to proceed further.

Congratulations! You have successfully installed Multiple PHP Version. Thanks for using this tutorial for installing Multiple PHP on Ubuntu 18.04 LTS (Bionic Beaver) system. For additional help or useful information, we recommend you to check the official PHP website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!