How to upgrade from PHP 7.0 to PHP 7.1 on Ubuntu

Posted Date : 21-09-2018

In this post we will explain upgrade from PHP 7.0 to PHP 7.1 on Ubuntu.

We assuming that you have have php 7.0 installed in your server. Please follow the and upgrade the php version from php 7.0 to php 7.1.

Step 1: Add ondrej/php PPA.

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

If you get a command not found error for add-apt-repository, you can install it from:

sudo apt-get install software-properties-common python-software-properties

Step 2: List your current PHP packages

dpkg -l | grep php | tee packages.txt

Step 3: Turn the web server off. After that, run the following.

sudo apt-get install php7.1 php7.1-common

This should install the basic packages on your system.
Now, make sure to install the additional packages as you need them. In my case, I also installed these packages with apt-get command.

sudo apt-get install php7.1-curl php7.1-xml php7.1-zip php7.1-gd php7.1-mysql php7.1-mbstring

Step 5: Remove old 7.0 packages
If everything works great, you can remove the old packages now.

sudo apt-get purge php7.0 php7.0-common

Step 6: Start the web server. Run the following command and see the php version

php -v


Leave a Reply