Home CMS Install WordPress 4.6 in Ubuntu 16.04 with LAMP stack [Updated]

Install WordPress 4.6 in Ubuntu 16.04 with LAMP stack [Updated]

By sk
Published: Updated: 348 views

There is no doubt that WordPress is the popular and most widely used Content Management System for websites and blogs. It is free, open source CMS based on PHP and MYSQL. As of April 2016, more than 60 million websites are powered by WordPress, and sure, the list will go on every year. We are also using WordPress CMS right now for our blog OSTechNix. WordPress CMS is created by Matt Mullenweg and Mike Little, and the first version of wordpress was released on May 27, 2003. WordPress is released under GPLv2 license, so anyone can download, modify and use it.

Install WordPress 4.6 in Ubuntu 16.04 LTS

In this tutorial, we will be discussing how to install WordPress 4.6 in Ubuntu 16.04 LTS server edition with LAMP stack. As of writing this guide, the latest stable version was 4.6.

Setup LAMP stack

Since WordPress is web-based CMS, we need to have a working LAMP (Apache, MySQL/MariaDB, PHP) stack in the Ubuntu server. To install LAMP stack, refer the following guide.

Create database for WordPress

After installing LAMP stack, we need to create a database and database user for WordPress. For the purpose of this tutorial, I am going to create a database called "wpdb" and database user called "wpuser" with password "ubuntu". I recommend you to use any strong password for the database user.

To do so, log in to MariaDB (Working with MYSQL and MariaDB is same) as root user:

mysql -u root -p

Run the following commands shown in black letters one by one to create database and database user.

Sample output:

Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 52
Server version: 10.0.25-MariaDB-0ubuntu0.16.04.1 Ubuntu 16.04

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> CREATE DATABASE wpdb;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> CREATE USER wpuser@localhost IDENTIFIED BY 'ubuntu';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON wpdb.* TO wpuser@localhost;
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit

sk@ubuntuserver: ~_001

Restart mysql and Apache services:

sudo systemctl restart mysql
sudo systemctl restart apache2

Download and Install WordPress 4.6

We have completed the necessary prerequisites. Now, it is time to deploy wordpress in our Ubuntu server.

Download the latest WordPress version using the following commands:

cd /tmp
wget http://wordpress.org/latest.zip

sk@ubuntuserver: -tmp_002

Extract the downloaded file as shown below:

sudo apt-get install unzip
unzip latest.zip

The above command will extract the zip file and saves the contents in a directory called "wordpress" in the /tmp directory.

Move the extracted folder (i.e wordpress) to the web root folder.

sudo mv wordpress/ /var/www/html/

Then, we need to set appropriate permissions to the following directories.

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

sk@ubuntuserver: -tmp_003

Create a directory called 'uploads' within the 'wordpress' folder, and set the appropriate permissions to that directory as shown below.

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

sk@ubuntuserver: -tmp_004

Now, open up the web browser of your choice and start the WordPress web installer by navigating to the URL: http://IP-Address/wordpress/ or http://domain-name/wordpress/.

You will be pleased with the following screen. Select your preferred language and click Continue.

WordPress › Setup Configuration File - Chromium_001

Install WordPress 4.6

Next, we need the following details.

  1. Database name
  2. Database username
  3. Database password
  4. Database host
  5. Table prefix (if you want to run more than one WordPress in a single database)

Once you have these details, click Let's go, else go back the section 'Create Database for wordpress', and create the required database details.

WordPress › Setup Configuration File - Chromium_002

Enter the correct database connection details which we have created earlier in the respective boxes below.

WordPress › Setup Configuration File - Chromium_003

If you have entered valid database details, you should see the following screen. Click 'Run the install' button.

WordPress › Setup Configuration File - Chromium_004

Next, enter your blog details, such as blog name, username, and password etc.

WordPress › Installation - Chromium_005

Congratulations! WordPress has been successfully installed in your Ubuntu server. Click Login to continue.

WordPress › Installation - Chromium_006

Enter your wordpress username and password.

OSTechNix Test site ‹ Log In - Chromium_007

This is how my Worpdress site dashboard looks like.

Dashboard ‹ OSTechNix Test site — WordPress - Chromium_008

Post installation

Here is some basic things to do after installing WordPress.

Fix upload problems in WordPress

When you try to export contents of your existing wordpress site, you might encounter with the following errors.

Sorry, there has been an error.
File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.

Import ‹ OSTechNix Test site — WordPress - Chromium_001

To fix this, edit php.ini file:

sudo nano /etc/php/7.0/apache2/php.ini

Find the following two values and set it to sufficient size, for example 50 MB.


post_max_size = 50M


upload_max_filesize = 50M


Save and close the file.

Restart Apache service to take effect the changes.

sudo systemctl restart apache2

Fix Permalinks error

WordPress offers you different cusotm URL structure. By default, the default URL of your posts will look like below.


To change it to something human-readable format, you must do some tweaks in the Apache configuration file.

To do so, edit /etc/apache2/sites-available/000-default.conf file:

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

Add or modify the lines marked in bold letters.

 <Directory /var/www/html/>
 AllowOverride All

sk@ubuntuserver: ~_002

Replace with your own IP address or domain name.

Then, enable the apache rewrite module that allows you to modify URLs using command:

sudo a2enmod rewrite

Finally, restart apache service to take effect the changes.

sudo systemctl restart apache2

Now, you can change the permalinks into user-friendly format in the Permalinks section.

You can check the Permalinks settings in Dashboard -> Settings -> Permalinks.

Permalink Settings ‹ OSTechNix Test site — WordPress - Chromium_003

Delete default pages and posts

WordPress fresh installation should come with a sample page, post, comment. We don't them any more.

Just log in to your dashboard and delete them.

Pages ‹ OSTechNix Test site — WordPress - Chromium_004

Similarly, go to posts and comments section, and delete all of them.

Comment moderation

This another important section to avoid spam comments. In this section, you can define section whether your comments should be moderated before appearing under your posts.

Here is my preferred settings:

Discussion Settings ‹ OSTechNix Test site — WordPress - Chromium_005

That's it. At this stage, you have a basic working WordPress blogging platform. Start writing your articles.

Want to learn for about WordPress? Download the following WordPress guides and resources for free:

Happy blogging!


Thanks for stopping by!

How can I benefit from this blog:

Have a Good day!!

You May Also Like

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More