Set up WordPress on Ubuntu 16.04 LTS

Please do not use this tutorial anymore, since there are too many bugs. I recommend you using Ubuntu 18.04 with this English tutorial or the Chinese version translated by me.

About the Title

I have already introduced WordPress to you, then what is Ubuntu 16.04 LTS?
Linux has a lot of branches and Ubuntu is a distribution of Linux, so shortly, a kind of Linux Operating System(OS). LTS is short for Long Term Support, which means this is a stable version of Ubuntu.


As I mentioned in this article, I have transferred my blog to Korea. Providers like Kdatacenter and BandwagonHost do not provide one-click WordPress and installing it can be really tedious as I mentioned in the Vultr one-click WordPress article. In this article, I will write about the whole process of setting up WordPress blog on Ubuntu 16.04 LTS(Only works on 16.04). This could be a hard process since there are tutorials out there but none of these are even 95% perfect. So what I am gonna do today is to get all these processes as simple as possible by referencing these tutorials and documentations.

Set up the LEMP Environment for you WordPress APP

LEMP: Acronym for Linux Nginx(short for Engine X) MySQL PHP

LEMP is the environment we need to host a full-stack (including dynamic UI, database and the interaction between) webpage, and the WordPress app itself is set of webpages(in .php format) to host based on PHP.  And a little bit different to .html(static webpage file) files, .php is a dynamic webpage, the corresponding .html file is generated at runtime and set to the client(someone just like you who is reading my blog). Nginx is the one that manages the server and MySQL is the database to store all the data of your webpage.

Then let’s get started!

Step 1: Install Nginx

What you need is a VPS installed Ubuntu 16.04. Typically, when you purchase a server from a provider, you will get 2 lines of the basic VPS information. 

  • The IP address of your server( It should be an IPv4 address like
  • The root password of the server

You can now add A record(s) at your DNS service provider for you server if you don’t want everyone have to remember the IP address to enter your blog and want to have an SSL certificate. (If you want to know how to, check out my another article). In my case, I had the following addresses bound to my blog:

On Windows, you need a command line tool like git , on macOS, you can use the embedded terminal to access your vps via ssh. Following is the command. (The second line is for some service providers like BandwagonHost, they provide random ssh_port). So just try the first line out, if it does not work, then try to find the port provided and then try the second line of command. 

> ssh [email protected]_vps_ip_address
> ssh [email protected]_vps_ip_address -p ssh_port

You should get a response like this

The authenticity of host '[your_vps_ip_address]:123 ([your_vps_ip_address]:123)' can't be established.
ECDSA key fingerprint is SHA256:W9v+UO4P4YSh3+beA0Mvn+U8WJduraPTAS5V16W8iYc.
Are you sure you want to continue connecting (yes/no)?

Input “yes” and Enter. Now you should have control and it prompts something like this and I will replace this with $ in this tutorial.

[email protected]:~# 

Input the following lines and press Enter one by one to have nginx installed. When it prompts you to choose between [Y/n], enter y (for yes). (After the installation, you should now have the directory /var/www/html generated, which is for your webpage to host. The version information about you nginx is all in the file index.nginx-debian.html, we will replace this file later with our wordpress webpages).

$ sudo apt-get update
$ sudo apt-get install nginx

Now open your browser and open the webpage and you’ll see a Welcome to nginx page.


Step 2: Install MySQL

Simply typing:

$ sudo apt-get install mysql-server

When it prompts you to set a password for your MySQL database root user, you can set it with the password you like, repeat entering it and remember it for later use.

To complete the configuration, typing

$ mysql_secure_installation
Enter password for user root: the_password_you_set

Press enter all the way until

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y

Enter y and you will see

All done!

Step 3: Install PHP for Processing

$ sudo apt-get install php-fpm php-mysql
Then configure the PHP Processor by editing its configuration file. (nano is a text editor)
$ sudo nano /etc/php/7.0/fpm/php.ini

Use Ctrl + W to search


and press enter you will see the line, delete the semicolon(;) in the front of the line and change the number 1 into 0. The press Ctrl + X, then Y, then Enter to save the change. The line should be like this in the end:


Restart the PHP processor by typing: 

$ sudo systemctl restart php7.0-fpm

Step 4: Configure Nginx to use PHP Processor

Refer to the Digital Ocean tutorial step 4 to complete Step 4.

In these steps, you can either use the ip address or the domain address you bind to your server ip.

Step 5: Create a PHP File to Test Configuration

Refer to the Digital Ocean tutorial step 5 to complete Step 5.

Get SSL Certificate for your blog

$ sudo apt-get update
$ sudo apt-get install software-properties-common
$ sudo add-apt-repository universe
$ sudo add-apt-repository ppa:certbot/certbot
$ sudo apt-get update
$ sudo apt-get install python-certbot-nginx 

After these installations, you can now start the interactive installer.

$ certbot --nginx --redirect

You are prompted to enter your email address, enter it. Then it comes a series of confirmations, firstly, enter a for (A)gree, then enter y for(Y), and in the end press Enter to install the certificate.

In the image, I use as an example, not the 3 urls above, your should be the same.

After a while, you should see IMPORTANT NOTES, then with one more line you can make your certificate renew automatically. (By default, it expires every other 90 days).

$ sudo certbot renew --dry-run

Set up WordPress 

Step 1: Get the WordPress web resource ready

$ cd /var/www/html
$ rm index.nginx-debian.html
$ wget
$ sudo tar xvfz latest.tar.gz
$ mv wordpress/* ./
$ rmdir wordpress
$ rm latest.tar.gz
$ sudo chmod -R 777 wp-content

You should execute these lines one by one. It basically removes the nginx default information page and then downloads the latest WordPress from https://www., decompress(tar xvfz) it and then move(mv) it to the web root directory(/var/www/html). The last line concerns about the access privilege in Linux OS, and it makes sure that the WordPress app has right to read and write the file.

Step 2: Create database for WordPress in MySQL

$ mysql -u root -p

This line helps you to login MySQL DB(Database) Server(-u for username, which is root here and -p for password). You should be prompted to Enter your password, just enter the one you set just now.

Then create a database for your WordPress app.

mysql> create database wordpress;
mysql> exit;

One more step to become a blogger pro

Enter your domain name or ip in the the browser and you should see a welcome page.

Welcome page of WordPress

Click Let’s go, in the new page, enter your username(root) and then enter your sql  database password. Click submit.

You should see a page like the following.

And then go back to your Linux ssh window. (If the connection is lost, close the terminal and make connection again.

$ sudo nano /var/www/html/wp-config.php

Copy the text paste it in the wp-config.php file.  Add the following line to the file as in the following picture. Then Ctrl + X, press Y and finally Enter to save changes in the file.

define('FS_METHOD', 'direct');

Then click Run the installation to continue your WordPress installation and configuration.

Now you can use your WordPress and What you see/do is what you get.

Issues found & Remaining:

  • The file upload maximum size is 2MB, I know the solution, not updated here yet.
  • The site some issue with the site logo, maybe due to lack of a Graphics package.
  • Due to file permission issues, WordPress Update may fail, I will cover the solution later.

References and thanks to: