How do i upgrade to Ubuntu 18.04 and Php latest version?

Posted March 3, 2020 35.1k views
PHPUbuntu 16.04

Hi all!

My wordpress shows the configuration - PHP 7.0.33-0 ubuntu

I want to upgrade my server to the latest versions of PHP and Ubuntu 18.04.

Please tell me the process to do it without creating a new server and migrating everything there.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

Hi @sid431,

Let’s start with the Ubuntu Upgrade first as it’s more important one.

Please make sure to backup your data first as updates quite often fail!

Ubuntu upgrade

The first step would be to make sure your current system is up to date. You can achieve this by running

sudo apt update && sudo apt upgrade

After it’s completion make sure either UFW firewall is temporarily disabled or TCP port 1022 is open. You can execute the following

sudo ufw allow 1022/tcp comment 'Temp open port ssh tcp port 1022 for upgrade'

Upgrade the operating system to the latest release from the command-line by typing the following command:

sudo do-release-upgrade

Now follow on-screen instructions. During upgrade procedure, you may be promoted to replace existing grub or ssh config file. Make sure you choose to keep existing version to avoid problems!

After some time you will see “System upgrade is complete” message. Press y to restart your system to load updates kernel and operating system for your cloud server

You’ll need to reboot your droplet now.

As soon as it’s powers on, close connections to your port 1022:

 sudo ufw delete allow 1022/tcp

That’s it, you should now have an updated Ubuntu version!

Please make sure to backup your data first as updates quite often fail!

Now to upgrade your PHP Version to 7.3.

Upgrade PHP to 7.3

The first important thing to know is that you won’t be actually upgrading the PHP version but installing the newest one as well.

You’ll need to add the proper repositories

sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update

Next depending on your WebService - Nginx/Apache you have different steps.

Let’s start with the Nginx requirements:

sudo apt install php7.3-fpm

To check this afterwards run

php-fpm7.3 -v

Now if you are using Apache :

sudo apt install php7.3

Now that you have the PHP version, you’ll need to install some extensions. You can do it like so

sudo apt install php7.3-extension_name

The most common extensions can be installed with the following command

sudo apt install php7.3-common php7.3-mysql php7.3-xml php7.3-xmlrpc php7.3-curl php7.3-gd php7.3-imagick php7.3-cli php7.3-dev php7.3-imap php7.3-mbstring php7.3-opcache php7.3-soap php7.3-zip php7.3-intl -y

That’s it.


  • Hi @sid431,

    I’ve been doing some tests in the recent days. If you create a new droplet and try with the solution of upgrading the OS, it works perfectly however it does seem to cause some issues when you actually have something else installed on.

    Despite my previous comment actually being a valid one, I’ll suggest actually migrating your website to a new droplet with an Ubuntu 18.04 installed by default!


    • HI KDSys..

      Thanks for your reply.. Earlier I was trying to find a way to upgrade the existing server which is about 2 years old as I was a bit reluctant to migrate everything to a new server.

      But I’m taking your suggestion to create a new droplet and migrating everything there.

      Thanks for your input.. Have a great day ahead

I have one more issue. If everything works fine for me, Wordpress thinks he always running on PHP7.0

Maybe a problem with apache2 ?

I’ve found tuto in order to fix that, but no works.


Edit : I’ve Found the answer

$ sudo a2dismod php7.0
$ sudo a2enmod php7.3
$ sudo service apache2 restart