Install WordPress on Ubuntu/Debian (or where’s my WordPress install and why isn’t it working)


I recently wanted to play with a local instance of WordPress (I am running Ubuntu 10.04 i386, but this should apply to all Debian based distros). I already had apache2, mysql and php up and running so decided to just try:

sudo apt-get install wordpress

WordPress installed and everything looked promising. But I could not find a URL that worked, or any configuration files in the /etc/apache2/conf.d directory (where most web applications usually put them).

It turns out there are a few more manual steps required. Hopefully this will be automated on later packages, but it doesn’t hurt to understand what’s going on under the hood sometimes. There are two main steps that need to be done:

Create apache configuration

Following the examples of other web applications, we can create a file in /etc/apache2/conf.d called wordpress.conf. This file should have the following (or similar) content:

Alias /blog /usr/share/wordpress
<Directory /usr/share/wordpress>
Options FollowSymLinks
AllowOverride Limit Options FileInfo
DirectoryIndex index.php
</Directory>

You can change /blog to whatever you want your WordPress install to be served under. As it is, you will find it at http://localhost/blog. Following this, restart apache to load the new configuration.

sudo /etc/init.d/apache2 restart

Run the mysql setup script

Next we need to run the setup-mysql script to create the right database users, tables etc. To do this, change directory to the /usr/share/doc/wordpress/examples folder where you will find the setup-mysql script. If you run:

sudo bash setup-mysql

you will get a simple explanation of how to use the script, as shown below:

setup-mysql [-n NAME] [-h | -d | -b] FQDN

Creates by default a WordPress mysql configuration depending on required fully
qualified domain name(FQDN).

Options:
-n name for the mysql user and database
-h help
-d destroy and purge
-b backup

Example: You want your blog to be served from http://blog.example.com
for user ‘wordpress’.

Then run:
sudo bash setup-mysql -n wordpress blog.example.com

Following this lead, you can just run:

sudo bash setup-mysql -n wordpress localhost

Assuming everything works without issues, navigate to http://localhost/blog and step through the 1 step process of the WordPress web based setup.

Leave a Reply