WordPress Permalinks not working on Ubuntu 10.04 – mod_rewrite issue requires a symlink

Ubuntu & WordPressI recently installed WordPressMU on a virtual server and had problem with the permalinks. Much Google searching followed with little success at first but after some persistence I found the answers I needed.

I will try and write this up for three reasons:

  1. So hopefully it could benefit someone else with the same problem
  2. To try and better understand it myself
  3. I will no doubt forget for next time and need to refer back.

The bulk of this post is taken from a fantastic post on the Drupal site (http://drupal.org/node/332318). Although I had done lots of Google searches I struggled to find the answer for quite some time until I hit the post above. I think this is because the key to finding the right answer for a problem is finding someone with the same set-up. Saying this I found the solution to my WordPress problem on Drupal site although the issue was with a common problem area of ‘mod_rewrite’ on the Apache web server and in particular the Apache server running on Ubuntu. Ubuntu has a different way of storing apache settings (e.g it has a blank htppd.conf and uses apache2.conf) and holds modules in an ‘enabled’ folder not in the main settings file. This may well be better way than the ‘other’ ways but it can mean that a lot of the mod_rewrite ‘solutions’ on Google are not relevant if they are not specifically for Ubuntu.

Just quickly for this project my setup was:

Virtual Server Provider: VPS.net

Base install: Ubuntu 10.04 (Lucid) x64 LAMP*

WordPress 3.0 (with Multisite enabled)

* This was a preconfigured Ubuntu server with LAMP already instated and my experience may have been different if I had taken a clean Ubuntu install and installed LAMP myself. VPS.net do a offer a fully preconfigured WordPress server in Ubuntu which I am sure would have not had these issues but I wanted to install WordPressMU and this requires the install to be on the www root (VPS.net install it on a folder called WordPress) and the latest version. In my way of thinking I would prefer to install from scratch on a clean webserver than upgrading/moving an existing install – OK I like to learn the hardway.

Anyway the solution to my problem:

1. First we need to check if the rewrite module is installed. I was connected to my VPS server via SSH but either in a Terminal or via SSH type (or copy from below):

apache2ctl -M

This should show a list of Apache modules. Rewrite_Module should be there (as it is a default in Ubuntu 10.04) but if not check with your FTP client or in your file browser that /etc/apache2/mods-available contains a file called rewrite.load. If it does not then you need to fix this before you can carry on.

Presuming it does exist then we need to create a symlink (Symbolic Link on Wikipedia) between mods-enabled to mods-available. Again in the Terminal/SSH type or copy:

cd /etc/apache2/mods-enabled
sudo ln -s ../mods-available/rewrite.load

2. Now we need to check that rewrite module rewrite.load is in the mods enabled folder (/etc/apache2/mods-enabled). The easiest way is to have a look at that folder with your FTP client or file browser.

3. Presuming you are still OK then then the final and very important stage is to ‘Enable AllowOverride All’

In the folder /etc/apache2/sites-enabled you should find a file called 000-default and you need to check that all permissions are set to read & write not just read only, easily done with an FTP client (right click file>File Permissions in Filezilla)

In 000-default it will probably say AllowOverride None in several places. Find the one for where you’ve installed WordPress , and change it to AllowOverride All. e.g if WordPress is installed at var/www/????? then it may be under the Directory “/var/www” grouping.

Finally, dont forget to restart Apache from the terminal:

/etc/init.d/apache2 restart

(now corrected see Keith’s comment)

if you don’t restart none of the changes will take affect

That worked for me and hopefully will work for somebody else. A big thanks to the Drupal site for the post but I thought it was worth regurgitating for WordPress users as I am sure it could affect a few.