Install Multiple PHP Versions on Ubuntu

Install PHP 5.6

Step 1: Update Apt-Get

As always, we update and upgrade our package manager before beginning installation. If you are currently running PHP 7.X, after updating apt-get, continue to step 2 to downgrade to PHP 5.6.

apt-get update && apt-get upgrade


Step 2: Install PHP 5.6

Install the PHP5.6 repository with these two commands.

apt-get install -y software-properties-common
add-apt-repository ppa:ondrej/php
apt-get update
apt-get install -y php5.6

PHP Version for Apache

Step 3: Switch PHP 7.0 to PHP 5.6
Switch from PHP 7.0 to PHP 5.6 while restarting Apache to recognize the change:

a2dismod php7.0 ; a2enmod php5.6 ; service apache2 restart

 

Note
Optionally you can switch back to PHP 7.0 with the following command:a2dismod php5.6 ; a2enmod php7.0 ; service apache2 restart

 

Now, let’s verify that PHP 5.6 is running on Apache by creating a PHP info page. To do so, insert the code below into a file named  phpinfo.php and upload it to the /var/www/html directory.

<? phpinfo(); ?>

By visiting http://xxx.xxx.xxx.xxx/phpinfo.php (replacing the x’s with your server’s IP address), you’ll see a PHP info banner similar to this one, confirming the PHP Version for Apache:

Comments

Popular posts from this blog

cpanel exam CPSP Answers

How to install zimbra collaboration suite 8.8.11 on CentOS 7

awstats installation