Search blog

Saturday, March 17, 2018

[Solved] - Install PHP 7.0, PHP 7.1 or PHP 7.2 in Ubuntu 14.04

After trying a couple of packages, settings and configuration, the solution below is finally what worked for me:

1. Update your PPA repository with the  PHP 7x package sources:

 sudo add-apt-repository ppa:ondrej/php
Press enter to confirm. If you come across any error then you will need to install the python-software-properties first as shown below:

NOTE: The above PPA is a co-installable one, meaning you can install PHP 5.5, PHP 5.6 or PHP 7.0 as per your requirement, and both your old and new versions of PHP can co-exist without you having to remove the old version.
 sudo apt-get update  
 sudo apt-get install python-software-properties  

2. Update

Once again update your packages:
 sudo apt-get update  

3. Install PHP 7.x and its relevant mods:

For PHP7.0: sudo apt-get install php7.0 php7.1-mbstring php7.0-mcrypt php7.0-mysql php7.0-xml php7.0-curl php7.0-intl php7.0-soap php7.0-zip php7.0-gd
For PHP7.1: sudo apt-get install php7.1
For PHP7.2: sudo apt-get install php7.2

4. Disable PHP 5.5 or 5.6:

Now this step is very important else you won't be able to use PHP 5.6. Even when you check your PHP version, it will still display as PHP 5.5. Follow the step below to disable PHP 5.5.

 sudo a2dismod php5
 or
sudo a2dismod php5.6

5. Enable PHP 7.x:

Note: Replace x with 0, 1 or 2, depending upon the version you want to install
 sudo a2enmod php7.x  

6. Restart Apache web server:

 sudo service apache2 restart  

Note: New location of php.ini file in PHP 5.6:

The location of php.ini fie is changed from PHP 5.6 onwards, unlike PHP 5.5 where it used to be located at '/etc/php5/apache2/php.ini'; the new location is at '/etc/php/7.x/apache2'

No comments:

Post a Comment

Thank you for your Feedback!
www.evagabond.me

Top 5 Posts (Weekly)