In this tutorial we are going to install a wordpress website on a LAMP stack. WordPress is the most used CMS worldwide so it’s a great pick for testing our LAMP configuration. If you don’t have a LAMP stack installed you should check this article-Installing LAMP on Ubuntu

Create a database and a username in MySQL

First we need to create a database and a user corresponding to it in MySQL. In order to do that we need to log in to the root administrative account in MySQL. Type the following command:

You’ll be asked for the password for the MySQL root user. Enter it.

Now you have access to MySQL. We are going to make the wordpress database. Use this command

We have to make a MySQL user for the database that we have just created and assign it a password.

Now we have to assign the newly created user to our wordpress database. In order to do that just type:

We have to flush the privileges in order for MySQl to know that we have made changes

We can exit mysql

Download WordPress

In order to download the most recent and stable version of WordPress type the following:

This will download a compressed file containing the wordpress installation files and folders. We have to extract those files into our home directory.

We have to install some additional modules in order to be able to install plugins in WordPress using our SSH login credentials.

Move WordPress files to Document root

In order for your website to be accessible you have to move your wordpress files to Apaches document root. The location of document root is /var/www/html/

It’s a good idea to create a separate directory for your wordpress installation. This way you can install multiple websites in your document root.

Now your wordpress files are moved to your document root thus making them accessible for your visitors.

After that remove the wordpress folder and latest.tar.gz  in your home directory

Our next task in to make changes to the wordpress config file

Configure WordPress

Navigate to /var/www/html/wordpress

We have to copy  the wp-config-sample.php to wp-config.php and to remove the wp-config-sample.php

Let’s open the wp-config.php and change some fields.

There are some fields which you need to change. We are changing them with the database and user in MySQL that we have made a while back.

Save the file and exit.

Now we have to give our server access rights to our wordpress directory. If we don’t do that we won’t be able to update plugins upload images etc.In order to accomplish that we have to login as root.

Enter your root password

Return to your normal user account

We have to grant read access to our general directory. In order to do that type:

Modifying Apache

In order to associate the domain we chose for our website with it’s proper location we have to make some changes

Now we have to edit wordpress.conf

We need to add the following lines

ServerName ServerAlias
Also we have to change this to your E-mail in order for you to receive E-mails

Save and exit


We need to enable our website

In order for changes to take effect type

To access your wordpress installation type the name of your domain in your browser and follow the installation instructions.

If you want to use wordpress pretty permalinks feature you have to make some changes in the host file.

You have to add those lines bellow DocumentRoot  /var/www/html/wordpress.

Save and close. Next we need to enable the rewrite module. This enables you to rewrite URL’s

restart the apache web server


We need to create a .htaccess file in order for wordpress to write changes to it.

To make the web server the group owner type

Our last step is to give the .htaccess file the right permissions

You can enjoy your newly installed WordPress website. Cheers!