Install WordPress on Ubuntu 16.04 – Beginner Guide [5 Minutes]

Install WordPress on Ubuntu 16.04 – Beginner Guide [5 Minutes]


Learn How to install wordpress on ubuntu 16.04.

WordPress is the best and most popular platform for creating websites and blogs. It will let you create websites easily with just drag and drop.

WordPress CMS is flexible and it makes anyone work with it easily. It powers single page website to million visitor blogs and eCommerce stores.

It works with PHP and MySQL. If you are a planning to move your wordpress blog from managed hosting to a server, then this guide will help you.

Nowadays, a lot of cloud service providers giving the small servers at very low cost. It can handle 20-30 times more traffic for the same money.

The problem with many people is they just can’t handle the server by themself. Here, i am going to make it easier for you today.

In this guide, let us how to install wordpress on Ubuntu 16.04 server. You can use the same method for other version of ubuntu also.

Install WordPress on Ubuntu


  • Ubuntu 16.04 server configured according to the following Ubuntu initial server setup guide. If you have not followed this guide, just follow and setup your server as mentioned there.
  • You should have installed, LAMP stack installed on your server. I have covered how to install lamp on ubuntu.

Creating MySQL Database for WordPress

As i have mentioned earlier, the wordpress requires MySQL to create and maintain database to store and retrieve data. Since, we are directly installing wordpress on the server, we have to manually create the database and user for it.

To log into the MySQL root, use the below command.

Now, we are going to create a database for wordpress. It will be only used by wordpress. To create, use the below command. We will name the database wordpress.

If you are not familiar with the MySQL, then always remember to add “;” at the end of each command in MySQL.

After the database creation, now create a MySQL user account which will be used for handling the database we created for wordpress.

Then, we have to grant the permission for that MySQL user to use the wordpress database.

You can create user, password  and grant permission using the below command.

Make sure, you choose the strong password for the user. Now, the user has the access to the database. Execute the below command to MySQL to process the update.

After that, exit from the MySQL using the below command.

Adding More PHP Extensions

If you have followed the LAMP stack tutorial, you might only installed the basic PHP setup.

“You can use this how to install wordpress on ubuntu 16.04 guide for install wordpress on ubuntu localhost in your ubuntu desktop version.

But, WordPress requires a lot of additional PHP extensions. It is because of the wide range of plugins being used and introduced everyday.

You can check the plugin documentation to find out which PHP extension has to be installed.

It is very easy to install those extensions, here we will install some basic extensions which is enough for the basic wordpress setup.

First update the package index using the below command.

Then, follow this command to install the additional PHP extensions.

If you install any new Plugins, just restart the apache to make the web server work with the new PHP extensions.

Enabling .htaccess File Usage

Here comes the interesting part. The Apache and wordpress is the best combination.

Do you know why?

It is because of the .htaccess file. You can do many things with the .htaccess file. WordPress and many of it’s plugins use the .htaccess file for directory tweaks and access control.

Also, the another main thing is mod_rewrite. This one is used for enabling the permalink in wordpress.

To enable the .htaccess file, open the apache configuration file using nano editor.

Inside the file, find the Directory block. Add the AllowOverride directive as mentioned below.

Once you are done with that, just save and close file.

Since we have enabled the .htaccess file, now we can enable the mod_rewrite.

Before restarting the apache, check for the syntax error in configuration file.

You should see an output like the below one.

Now, restart the apache web server using the below command.

Download and Install WordPress

First, we have to download the wordpress from the official site. Whenever there is an update to the wordpress, we can get the latest one from their official site.

First, move to the /tmp directory.

To download the wordpress, execute the below command.

To unpack the archive, follow this one.

Create a .htaccess file and change the permission for it inside the directory.

Now, copy the wordpress sample file to the original one.

Here, we will create the upgrade directory to for wordpress. It will be required for wordpress to update itself in near future.

Once the above process is completed, now, it’s time for us to move the entire wordpress setup into the directory from where the wordpress contents will be served by the web server software.

Here -a will maintain the permission level.

WordPress Configuration

The main thing here is file permissions. Some times, we have to manually change the files and some times the web server has to read and write on some files.

If we do not set permission for the web server, it will cause problems later on. Here, we will assign permission to the user. Here is the command for that.

When new directories are created, they have to inherit their parent directories. This can be done by executing the below command.

After that, we have to enable the group write access to the wp-content.

Here comes the main task. As we have discussed earlier, we should give web server access to write on two main folders.

To install wordpress securely, we have to provide some values. To get that, execute the below command.

You will get the following output.

Then open the wp configuration file and paste these value in the appropriate place.

After that, find the below mentioned values and fill them with the appropriate credentials.

Then, save and close the file.


Go to the browser and enter your server IP address. From there, you will be taken to the WordPress setup wizard.

It is an easy one for everyone. Just finish the setup and start with the site.


In this tutorial, you have learned how to setup the wordpress on Ubuntu. When you go with a service provider, they will charge you a lot for small resources.


Establishing one the cloud will help you to save resource and gives you more control over the server and wordpress management.


Leave a Reply

Your email address will not be published. Required fields are marked *