Installing WordPress CMS On Ubuntu

This is a quick start guide to get you up and running with your own self hosted WordPress Content Management System. This guide was written using LAMP and Ubuntu 10.04.3 LTS Server, though it should work on other versions of Ubuntu or Debian with minor changes.

Installing LAMP

If you do not already have a LAMP stack installed it is required for this. You may install the LAMP stack by doing the following

sudo apt-get install lamp-server^

Installing WordPress

This guide assumes you are using a default web root to house your WordPress install, however if you want to place it else where that is fine just change the path as necessary.

To download the latest version of the WordPress CMS do the following.

cd /var/www
sudo wget

Then decompress it.

sudo tar xvf latest.tar.gz
sudo rm latest.tar.gz
sudo mv /var/www/wordpress/* /var/www
sudo rm -rf wordpress

The second line simply removes the archive we no longer need, and the third line moves the files from the subdirectory wordpress to our webroot. We can maintain it as a subdirectory if we want, but for this I want it in my web root to simplify things. The last line just cleans up the extra directory left behind.

Configuring the Database

The next portion requires us to configure a MySQL database for our WordPress install to utilize. We can do this by doing the following

mysql -u root -p

You will be prompted for a password, this is the database root password you configured when you installed LAMP.

GRANT ALL PRIVILEGES ON wordpress.* TO "wordpress"@"localhost" IDENTIFIED BY 'password';

The first line creates our database which is called wordpress, you may call it whatever you want. The second line grants all privileges to the database we created to user wordpress logged on from localhost, with the password ‘password’. Change the password to whatever you want, as well as the user just make note of it. The third line reloads our users and privileges to make our changes effective in the cache. Finally we exit the admin tool.

Configure WordPress

Finally we need to log in to our CMS and configure our database and user. We do this by visiting http://localhost/wp-admin/install.php where localhost is whatever your server’s IP or domain is.

You will be prompted with a screen that tells you to create a configuration file.

You will then be reminded that you need to know your database password and user, this is the information we just created in MySQL admin.

After you’ve entered the appropriate information into the form go ahead and submit. At this point you will be told WordPress could not write the configuration file, this is good, you really don’t want it to be able to write into your web root. It will however present you with the configuration file it should have written.

note : do not close your browser window, you will need to come back to this point.

We want to copy the contents of this file and place them in a file called wp-config.php

Still in our web root (/var/www) we want to create a file called wp-config.php

sudo vi wp-config.php

*Note : use nano or whatever text editor is easiest for you. Remember to prepend it with sudo.

Then insert the contents of the file that WordPress generated for you into this file, and save it. Now simply return to your browser window and click “Run Install”

You will be presented with another form to configure your site title and username, password and email address.

Once you have filled this information out click on “Install WordPress”.

Afterwards you should be taken to a login prompt for the username and password you just created and your WordPress Dashboard. At this point you’re good to go.


Creating fancy permalinks – If you want the fancy permalinks for your posts like as opposed to

You can do this easily by creating a .htaccess file in your /var/www with the following contents

RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

Then simply set your permalink settings the way you wish in your WordPress Dashboard (Settings > Permalinks).

Note : Make sure you restart Apache2 afterwards

sudo /etc/init.d/apache2 restart

A little Added Security – If you only access your blog from home, or a set IP range you can edit the site file /etc/apache2/sites-available/default in this case, however if you’re using Virtual Hosts your file may be different.

                Options -Indexes FollowSymLinks MultiViews
                Order deny,allow
                deny from all
                allow from

Add this in yourDirective and save the file, this will allow only IP addresses from the network to access your admin dash.

A LOT of Added Security – If you really want to tune the security of your new web application you can install a web application firewall with mod-security , check the guide here for doing that on Ubuntu.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s