We recently moved our production servers to Ubuntu 18.04 from 16.04 LTS… This post shows students and new users how we did it.

Before going any further, I want to make this clear… we do not upgrade Ubuntu servers.. period!

We normally install a new Ubuntu server from scratch and migrate our databases, content and others configurations to the new servers… We don’t believe in doing a in-place upgrade on existing servers… There are many things to account for when doing that…

So, If you’re currently running Ubuntu 16.04 LTS with Nginx, MariaDB and PHP, and you want to move to 18.04, the steps below should be a great place to start…

Here’s how we moved our WordPress sites from Ubuntu 16.04 to 18.04:

We host multiple WordPress websites on a single Ubuntu server…. All the sites have individual databases and web directories… but share the same IP address..

Step 1: Preparing Ubuntu 18.04 LTS

While your current Ubuntu 16.04 server is still operational, go and stand up a new server and install Ubuntu 18.04 Minimal edition…

After installing, run the commands below to update / upgrade all packages on the server…

sudo apt update && sudo apt dist-upgrade && sudo apt autoremove

The commands above should upgrade all packages that need to be upgraded… once done, restart the server and continue below:

Step 2: Install Nginx HTTP Server

Now that Ubuntu 18.04 Server is updated, you can now start installing apps servers… Your goal is to install the same servers you have on the Ubuntu 16.04 box… however, for us, we installed the latest servers on our 18.04 box….

To install Nginx, run the commands below

sudo apt install nginx

After installing Nginx webserver, run the commands below to add Nginx repository so you can install the latest version….

Doing the installtion, you should be prompted to type MariaDB root password at the end… do it

Step 4: Install PHP7.2-FPM and Related Modules

Next, on the list is PHP 7.2-FPM.. In our environment, we have sites that run on older version of PHP… so we needed to install PHP 7.2-FPM and PHP 7.0-FPM… You can’t install PHP 7.0-FPM on Ubuntu out of the box… to install older versions, you may have to add the PPA below… then install..

Then copy and replace the /var/www/html with the one from the 16.04 server… do the same for the other configurations….

For the databases, run the commands below to import them…

sudo mysql -u root -p < alldb.sql

Validate all your settings and file… and make sure everything is in the correct place… Also, don’t forget PHP settings… Make sure your PHP settings match that of Ubuntu 16.04 on the new server…

Check Nginx configuration by running the commands below…

sudo nginx -t

If it comes back with errors, look for where the error is and fix…

Look over all the configurationsl… and if everything is right, the new server should be ready…. Now all you hae to do is switch the Server IP address to the new server in the DNS settings and that’s it!