How to Install WordPress 4.7 on Ubuntu 16.04 with Apache, MariaDB, PHP7

WordPress 4.7, codenamed “Vaughan”, was released on December 6, 2016. Existing WordPress users can push the update button to upgrade to the latest version. This tutorial is going to show you how to install a new WordPress 4.7 instance on Ubuntu 16.04 with Apache, MariaDB and PHP7.

Here is what’s new in WordPress 4.7:

  • A brand new Twenty Seventeen theme for businesses
  • Starter content support for themes
  • Video header support
  • PDF previews
  • Custom CSS in customizer
  • User-specific language settings
  • Improvements in WordPress editor
  • Other developer features

This tutorial assumes that you have already set up a LAMP stack on Ubuntu 16.04. If not so, please click the link below to check out the LAMP tutorial.

After finishing LAMP installation, come back here and read on.

Step 1: Download WordPress 4.7

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

sudo apt update && sudo apt upgrade

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


Once downloaded, extract the archive using the command below.

tar xvf latest.tar.gz

A new directory named wordpress will be created in the current working directory. Now We move this directory and all its content to Apache web root. Replace with you real domain name.

sudo mv wordpress/ /var/www/

Step 2: Create a Database and User for 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 that you entered the correct password, then you can switch to root user first,

sudo su

Then run the command below to log into MariaDB shell.


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

create database wordpress;

Then enter the command below to create a database user for WordPress. This command also grant all privileges on WordPress 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: Configure WordPress

Go to your WordPress site installation directory.

cd /var/www/

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 in the previous step.

/** 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 the Apache user (www-data) as the owner of the WordPress site directory using the following command.

sudo chown www-data:www-data /var/www/ -R

Step 4: Create an Apache Virtual Host file for WordPress

First, cd into /etc/apache2/sites-available/ directory.

cd /etc/apache2/sites-available/

Then copy the default virtual host file.

sudo cp 000-default.conf

Next, edit the virtual host file for WodPress.

sudo nano

Change the values for ServerName and DocumentRoot like below.


ServerAdmin [email protected]
DocumentRoot /var/www/

Save and close the file. Then test configurations.

sudo apache2ctl configtest

Enable this virtual host.

sudo a2ensite

And reload Apache for the changes to take effect.

sudo systemctl reload apache2

Set a correct A record for your domain name, then enter your domain name in browser address bar. You shall see the WordPress installation wizard. Select a language.

install wordpress ubuntu

If the installation wizard isn’t displayed, then you probably should install some PHP7 extensions.

sudo apt install php7.0-mbstring php7.0-xml php7.0-mysql php7.0-common php7.0-gd php7.0-json php7.0-cli php7.0-curl

Then reload Apache and the wizard should be displayed.

sudo systemctl reload apache2

Create an admin account and click install WordPress button.

wordpress 4.7 ubuntu 16.04

And now your new WordPress site is ready.

wordpress apache config

Installing a TLS Certificate

To enable HTTPS connection on your WordPress site, you can use Let’s Encrypt. First, install Let’s Encrypt client (cerbot) on Ubuntu 16.04.

sudo apt install letsencrypt python-letsencrypt-apache

Then run the following command to install a free TLS certificate.

sudo letsencrypt --apache --agree-tos --email your-email-address -d

You will be asked to choose easy or secure. It’s recommended to choose secure so that all http requests will be redirected to https.

let's encrypt apache

Once you hit the OK button, a free TLS/SSL certificate is obtained and installed on your Apache server.

Now visit your WordPress site again. You will see that it’s automatically redirected to https.

That’s it!

I hope this tutorial helped you install WordPress on Ubuntu 16.04 with Apache, MariaDB and PHP7. As always, if you found this post useful, then subscribe to our free newsletter. You can also follow us on Google+ Twitter or like our Facebook page.

Rate this tutorial
[Total: 10 Average: 4.4]

3 Responses to “How to Install WordPress 4.7 on Ubuntu 16.04 with Apache, MariaDB, PHP7

  • Chase Wright
    4 years ago

    Hey great guide, thank’s for the tutorial. However, I’d like to point out one gotcha. If you follow your first guide to install Apache2 and you modify the ProxyPass for PHP-FPM that modifies the 000-default.conf file, and when you copy that to make your site using this tutorial you have to go modify the fcgi://localhost/var/www/html part (from html to

  • jenkinsm74
    4 years ago

    Hi there

    Just wondering could you do a tutorial on setting up a multi site wordpress on the same server ?


    • Xiao Guo-An (Admin)
      4 years ago


      The tutorial was just published ->

Leave a Comment

  • Comments with links are moderated by admin before published.
  • Your email address will not be published.
  • Use <pre> ... </pre> HTML tag to quote the output from your terminal/console.
  • Please use the community ( for questions unrelated to this article.
  • I don't have time to answer every question. Making a donation would incentivize me to spend more time answering questions.

The maximum upload file size: 2 MB. You can upload: image. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop file here