Install WordPress 4.6 on Ubuntu 16.04 with Nginx, MariaDB and PHP7

March 17, 2020

WordPress is the most popular open source content management system. WordPress version 4.6, codenamed “Pepper” was released on August 16, 2016. Existing WordPress users can just push the update button to upgrade to 4.6. If you are going to install WordPress from scratch, you have to come to the right place because this tutorial is going to show you how to install WordPress 4.6 on a Ubuntu 16.04 VPS.

WordPress 4.6 features includes:

  • streamlined updates: Install, delete, update plugins and themes without having to go to a new page.
  • Native fonts: The WordPress dashboard will now display your local installed fonts instead of fetching Open Sans font from the Internet, thus loading times are reduced.
  • Inline link checker
  • Content recovery: WordPress will save your edits to your browser in case unexpected things happen.
  • Resource hints makes your site even faster.
  • Robust Requests
  • Meta Registration API has been expanded.
  • Updated several JavaScript libraries including Masonry 3.3.2, imagesLoaded 3.2.0 etc.
  • Multisite is faster.

This tutorial assumes that you have already set up a LEMP stack on Ubuntu 16.04. If not so, click the link below to check out my easy to follow guide. WordPress also works with LAMP, but here I show you how to set it up with LEMP.

Install Nginx, MariaDB and PHP7 (LEMP Stack) on Ubuntu 16.04 LTS

When you are finished, come back here and read on.

Step 1: Install WordPress 4.6 on Ubuntu 16.04

Log into your Ubuntu 16.04 VPS via SSH, then update all software.

sudo apt update && sudo apt upgrade

Next, download the latest WordPress tar archive to your Ubuntu 16.04 VPS which can be done with the following command:


Once downloaded, extract the archive using the below command.

tar xvf latest.tar.gz

A new directory named wordpress will be created in the current working directory. Now We create another directory in Nginx web root and then move all files under WordPress to it. Replace with you real domain name.

sudo mkdir /usr/share/nginx/
sudo mv wordpress/* /usr/share/nginx/

Step 2: Create a Database and User for your WordPress Site

Log into MariaDB shell as root. Please note that this is the MariaDB database root user, not the root user of Ubuntu 16.04 system.

mysql -u root -p

If you can’t login but you are sure you entered the correct password, then check out the following post to see how to solve this problem.

How to Fix MariaDB Plugin ‘unix_socket’ is not loaded Error

Once you are logged in, create the database using the following command. I named it wordpress, but you can use whatever name you like such as you site name.

create database wordpress;

Next, create a database user. Replace wpuser with your desired username.

create user wpuser@localhost;

Set a password for this user.

set password for wpuser@localhost= password("your-password");

In order to create database tables within the database, you need to grant privileges on the database to the user.

grant all privileges on wordpress.* to wpuser@localhost identified by 'your-password';

Flush the privileges table for the changes to take effect and then exit out of MariaDB shell.

flush privileges;

Step 3: Configuring WordPress

Go to your WordPress site root directory.

cd /usr/share/nginx/

Copy the sample configuration file.

sudo cp wp-config-sample.php wp-config.php

Now edit the new config file.

sudo nano wp-config.php

Find the following lines and replace the red texts with the database name, username and password you created above.

/** The name of the database for WordPress */
define('DB_NAME', 'database_name_here');
/** MySQL database username */
define('DB_USER', 'username_here');
/** MySQL database password */
define('DB_PASSWORD', 'password_here');

Save and close the file. We also need to set Nginx user (www-data or nginx) as the owner of the WordPress site root directory. You can check the Nginx username in /etc/nginx/nginx.conf file.

sudo chown nginx:nginx /usr/share/nginx/ -R


sudo chown www-data:www-data /usr/share/nginx/ -R

Step 4: Create a Nginx Server Block Config file for WordPress

sudo nano /etc/nginx/conf.d/

Put the following texts into the file. Replace the red texts with your own domain name. You also need to create A record in DNS for your domain.

server {
  listen 80;
  root /usr/share/nginx/;
  index index.php index.html index.htm;
  error_page 404 /404.html;
  error_page 500 502 503 504 /50x.html;
  location = /50x.html {
    root /usr/share/nginx/html;
  location / {
     try_files $uri $uri/ /index.php;
  error_page 404 /404.html;
  error_page 500 502 503 504 /50x.html;
 location ~ .php$ {
   try_files $uri =404;
   fastcgi_pass unix:/run/php/php7.0-fpm.sock;
   fastcgi_index index.php;
   fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
   include fastcgi_params;
   root /usr/share/nginx/;

Save and close the file. Then test Nginx configuration.

sudo nginx -t

If the test is successful, reload Nginx.

sudo systemctl reload nginx

The Final Step: Finish the WordPress Installation in Your Browser

Make sure that your domain name is pointed to your Ubuntu 16.04 VPS in DNS. Then in your browser address bar, type


You will see the WordPress installation wizard. Select your Language, click Continue and then create an admin user. And you are done!


Now you can start customizing your WordPress site.


Need help?

Do you need help setting up this on your own service?
Please contact us and we’ll provide you the best possible quote!