How to install Wordpress 4.5 on Ubuntu 16.04 LAMP

This document describes how to install and configure Wordpress 4.5 on Ubuntu 16.04. WordPress started in 2003 with a single bit of code to enhance the typography of everyday writing and with fewer users than you can count on your fingers and toes. Since then it has grown to be the largest self-hosted blogging tool in the world, used on millions of sites and seen by tens of millions of people every day. This tutorial explains the process of installing Wordpress 4.5 on Ubuntu 16.04 in the form of a simple-to-follow guide.

1 Preliminary Note

This tutorial is based on the Ubuntu 16.04 server installation CD. You have to set up a basic Ubuntu 16.04 (Xenial Xerus) server installation before you continue with this tutorial. The system should have a static IP address. I use as my IP address in this tutorial and as the hostname.  The server must have a LAMP server installed in Ubuntu 16.04 e.g. as described in this tutorial before you proceed.

2 WordPress Database initialization

I will create  the database for Wordpress as follows. Login to the MySQL or MariaDB database as root user:

mysql -u root -p

And create a database with the name wordpressdb, a user with the name wordpressuser and the password wordpresspassword. Please use different and secure password on your installation, the password used here is just an example!

CREATE DATABASE wordpressdb;

CREATE USER [email protected] IDENTIFIED BY 'wordpresspassword';

GRANT ALL PRIVILEGES ON wordpressdb.* TO [email protected];

Then exit the MySQL shell:


Restart services

service apache2 restart
service mysql restart


3 Installation of WorPpress 4.5

Go to the /tmp directory in which we will the download the latest version of the WordPress as follows:

cd /tmp

We have to install unzip to unpack the WordPress archive:

apt-get install unzip

Unzip the WordPress zip archive in the /var/www/html folder:

unzip -q -d /var/www/html/

Now set appropriate permissions for the WordPress directory.

chown -R www-data:www-data /var/www/html/wordpress
chmod -R 755 /var/www/html/wordpress

Further, we need to create the uploads directory beneath the wp-content directory at our document root. This will be the parent directory of our content: 

mkdir -p /var/www/html/wordpress/wp-content/uploads

We need to allow the web server itself to write to this directory. We can do this by assigning user and group ownership of this directory to our web server user www-data. This will allow the web server to create files and directories under this directory, which will permit us to upload content to the server. Proceed like this:

chown -R www-data:www-data /var/www/html/wordpress/wp-content/uploads

Now proceed to the web installation of Wordpress. Go to the URL in your web browser. The WordPress installer will show up.

Select language and press Continue:

Select the language in WordPress  

The welcome screen shows up in the selected language. Click on Let's go.

The WordPress welcome screen in your language shows up.

Type in the Login details of the WordPress database that we created in step 2. The database host is "localhost" and the prefix can be left at its default. Then click on the "Submit" button.

Enter the WordPress database details.

Wordpress saves the database configuration details to the file /var/www/html/wordpress/wp-config.php. Click on "Run the install" to proceed to the next part of the installer.

Now enter some details for the Blog like website title, admin username, password and email address. I used these values:

Site Title = My Wordpress Blog
Admin Email = [email protected]
Username = admin
Admin password = howtoforge

The above values are just examples and you should use the real title and email address here. Using admin as administrator name is ok for an internal website but you might want to use a nonstandard name or your personal name instead.

Set the WordPress title, username and password.

The press InstallWordpress to finish the installation:

Wordpress installation finished.

Now we will proceed towards the login page by pressing LogIn:

WordPress Login page.

Type in the credentials that you selected during WordPresspress installation. The WordPress Dashboard will show up.

The WordPress Dashboard.

This part is optional.

By default, WordPress creates URLs dynamically that look something like this http://server_domain_name_or_IP/?p=1. This isn't exactly the most useful interface for visitors or search engines, so most users want to modify this. WordPress has the ability to create "pretty" permalinks which will clean up the URL into a more human-friendly format. The following steps show you how to setup pretty permalinks in your WordPress Blog.

6.1 Apache Rewrite

We will modify the apache virtual host file for Wordpress 4.5 to allow .htaccess overrides. Add the following (red) lines in the 000-default.conf file:

nano /etc/apache2/sites-available/000-default.conf

ServerAdmin [email protected] DocumentRoot /var/www/html ServerName <Directory /var/www/html/> AllowOverride All </Directory> [...]

Next, we have to to enable the Apache rewrite module. Run:

a2enmod rewrite
service apache2 restart

Now we can easily adjust the permalink settings through the WordPress administration interface. Go to Settings-->Permalinks:

I'll choose "Post name" as Pretty-Link format for my blog so that the Post title is used in the URL.

When you have made your selection, click "Save Changes" to generate the rewrite rules.

Congratulations! You now have a fully functional WordPress 4.5 instance on your Ubuntu 16.04 :)

Share this page:

15 Comment(s)

Add comment


From: Adam at: 2016-05-10 22:21:15

I wanted to thank you for a well written article.  Just FYI this will not work on Comcast.  Well not on the average Comcast service anymore.  You can thank them for blocking port incomming port 80.  I was trully confused why my server was not being port forwaded on an incomming 80 to internal ip 80 when all was well internally.

It turns out comcast blocks incomming 80 now.  I changed the incomming port to 6969 and added :6969 to the end of the url and it worked. 

Just an FYI on those that become confused like I did.  You might add that little tidbit to your article.  It is what I used to build my webserver in the first place.

Kind Regards to you all

From: Kyle at: 2016-05-11 10:20:30

THANK YOU! By far the most thorough and helpful tutorials I've read.

From: QUHO at: 2016-06-07 20:30:44

Thank you!!!

Just follow the tutorial and everything works!!!

Thanks again! :)

From: Surya at: 2016-07-11 02:35:04

Thank you very much, it worked perfectly on my Ubuntu 16.04 desktop.

From: Paul at: 2016-07-11 11:47:25

Excellent guide and very straightforward!

Thank you very much for your work.

Regards, Paul.

From: sasa at: 2016-07-15 20:14:36

after 6.2 i destroyed my web page

From: Mridul Saikia at: 2016-07-16 11:49:50

hey can you please guide us more about Digital Ocean Server optimization

From: Raymond Day at: 2016-08-01 20:04:40

Very good how to install WordPress on a new system. The only problem was when WordPress wanted to link up to the Database. I know the name and password to the database was right but it was the Database name had to ad the db at the end. I guess you should say this or when making the database don't add the db at the end.

Thank you.

From: Raymond Day at: 2016-08-01 20:07:31

O yes I install this on a super small Nanopi. Tested out this WordPress on it some and don't see a slow down on this little board. They did a good job on this think.

I had to hook up a RS232 to it till it got a IP address. Then could just go to it's IP.

Thank you.

From: Gison Cargo at: 2016-08-16 15:40:26

 Hello my wordpress has been installed here how can I make it to

From: Eleazar at: 2016-09-06 17:55:32

Thank you very much! it was really useful!

From: Ale at: 2016-09-08 17:48:31

Great !!!Works fine for me. Thank You for the tutorial.

Cheers bro

From: Piotr at: 2016-09-10 16:00:12

Good job! Everything works nicely under Linux Mint 17.3 Rosa

From: Patrick at: 2016-09-13 21:44:23

Getting this error. "The uploaded file exceeds the upload_max_filesize directive in php.ini."  I've tried adding the following to .htaccess but it does not work. 

php_value upload_max_filesize 64M php_value post_max_size 64M php_value max_execution_time 300 php_value max_input_time 300

I modified the php.ini file in /etc/php/7.0/cli and still not working.  Why is it so difficult to fix this issue.  WP should ask you to change this during the install.  With the size of media today 2MB is just a rediculously small file size to default too.

From: till at: 2016-09-14 06:03:38

The file /etc/php/7.0/cli/php.ini id for the commandline php. Edit /etc/php/7.0/apache2/php.ini instead and then restart the web server.