How to update php 7.0 to 7.2 on ubuntu 16.04

Hello, Thi is another tutorial for an issue I got when I was working with Jenkins build. I really didn’t know much about the Jenkins part before. But I could learn it until pulling the bitbucket repo to the Jenkins build. However, I just tried with Jenkins shell script and My project was a lumen project. So, I ran the composer install line on the shell script. Then I got some errors on my build console of Jenkins.

Composer not found, PHP not found, were my errors. However, I installed both PHP and composer on my ubuntu. Then I saw an issue on my console about PHP version incompatibility. So I had to change it to make that build success.

However, Let’ get into the topic. You just have to use the following lines for your PHP version upgrade on your VPS or any ubuntu platform. Tested on 16.04 or later.

If you don’t have root access, just run the following to log in, else skip it.

sudo -i

Add the following repo. Sometimes, if you got an error when running the following command, you will have to use this link to solve it.

add-apt-repository ppa: ondrej/php

Just Update all using the following command.

apt-get update

Remove old PHP version

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

Install new PHP versions and all the extensions you need.

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

That’s all guys. Sometimes your process will be ended in the purging section, because if your VPS provider supports the latest version. Just try it and let us know in the comment section. Thank you for reading until the end of this post.