Typically, the host supervisor used a separate server for every PHP model software deployment. Which will increase the internet hosting value. Among the host managers are utilizing Docker to run a number of PHP model on the one server. Additionally, most of you’re conscious of the configuration, I used on this tutorial. However a few of the system directors usually are not conscious of this. This tutorial will enable you to to put in a number of PHP model with Apache on Ubuntu 20.04 Linux system with out switching PHP variations.

This tutorial describes the set up and configuration of two VirtualHost on Apache with separate PHP variations. First VirtualHost will work with PHP 5.6 and one other VirtualHost will run with PHP 7.2. So simply undergo this tutorial. You may also use greater than two PHP variations with Apache as required however this tutorial covers two solely.

Putting in Apache

Apache internet server packages can be found beneath the default repositories. Open a terminal in your Ubuntu system, then execute the next instructions to put in the most recent accessible model of Apache internet server.

sudo apt replace
sudo apt set up apache2 libapache2-mod-fcgid

Putting in PHP

A PPA is maintained for PHP set up on Ubuntu methods from an extended years. You simply want so as to add that PPA to your system to put in packages. Use the beneath couple of instructions so as to add the PPA to your system.

sudo apt set up software-properties-common
sudo add-apt-repository ppa:ondrej/php

For this tutorial, we’re utilizing the PHP 5.6 and PHP 7.Four to configure with Apache internet server. To make use of the a number of PHP variations, we are going to use PHP FPM and FastCGI. Let’s set up the next packages in your system.

sudo apt replace -y
sudo apt set up php5.6 php5.6-fpm -y
sudo apt set up php7.Four php7.4-fpm -y

After set up, php-fpm providers can be began routinely. Use the next instructions to ensure each providers are working.

sudo systemctl standing php5.6-fpm
sudo systemctl standing php7.4-fpm

Configure Apache with A number of PHP

Now allow few modules required for the configuration of a number of PHP variations with Apache. These modules are essential to combine PHP FPM and FastCGI with Apache server.

sudo a2enmod actions fcgid alias proxy_fcgi

Prepare for the configuration of internet sites in your Apache server. For the testing objective, I’m configuring two web sites to work with two different-2 PHP variations. First, create two directories in your server.

sudo mkdir /var/www/php56-app
sudo mkdir /var/www/php74-app

Now, create and index.php containing the phpinfo(); operate.

echo “” > /var/www/php56-app/index.php
echo “” > /var/www/php74-app/index.php

Let’s begin the creation of VirtualHost. Apache retains all of the VirtualHost configuration information beneath /and many others/apache2/sites-available with the extension .conf. Create a file for the primary digital host and edit in your favourite textual content editor.

sudo vim /and many others/apache2/sites-available/php56.instance.com.conf

Add the next content material. Make certain to make use of appropriate ServerName and listing path in accordance with your setup. This web site is configured to work with PHP 5.6.

Equally, create a second VirtualHost configuration file to work with PHP 7.2. Edit configuration file in textual content editor:

sudo vim /and many others/apache2/sites-available/php74.instance.com.conf

Add the next content material to file with correct ServerName and DocumentRoot.

You each of the web sites are configured now. However they’re nonetheless not lively. Apache retains lively websites beneath /and many others/apache2/sites-enabled listing. You may merely create a symbolic hyperlink of config information to this listing or use beneath command to do the identical.

sudo a2ensite php56.instance.com
sudo a2ensite php74.instance.com

After making all of the adjustments restart Apache to reload new settings adjustments.

sudo systemctl restart apache2

Your setup has been accomplished now. Go to the subsequent step to check your setup.

Take a look at Your Setup

Edit /and many others/hosts file in your native system and make an entry like beneath. This can resolve momentary names to localhost IP handle.

sudo vim /and many others/hosts

Add following entry to finish of file php74.instance.com php56.instance.com

Open an internet browser and go to each of the websites. You will notice that php56.instance.com reveals the model PHP 5.6 and php74.instance.com is displaying the PHP 7.Four because the configuration.


How to install a multiple PHP version of Apache on Ubuntu 20.04?


How to install a multiple PHP version of Apache on Ubuntu 20.04?


This tutorial lets you setup a number of web sites with different-2 PHP model on single Apache server on a Ubuntu 20.04 system.