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.

38 Replies to “WordPress Permalinks not working on Ubuntu 10.04 – mod_rewrite issue requires a symlink”

  1. Just as an FYI, Debian and Ubuntu provide helper scripts for managing modules and sites under apache. The “a2enmod” and “a2dismod” commands will enable and disable modules.

    So you could have done: a2enmod rewrite

    If there had been a separate heades.conf file, this would have symlinked that as well.

    1. @7290fff921620ec474cb19da58077ac3:disqus Thank for the suggestion about running the command sudo a2enmod rewrite.   I had tried everything else with no success until i ran the command you suggested!!

  2. Dude,

    Thanks for the post! I could not get the permalinks options work on localhost using Ubuntu 10.04 for love or money. My mod_rewrite was installed, so I was stuck. However, if you go to the permalink page, you’ll see an ominous message stating ” update .htaccess file.” Further down, you’ll find the text required. Cut and paste the file into your root directory. In my case, it was /var/www/blog. Caution! You may have an .htaccess file, but it may not contain the correct info, so copy the new info provides by WordPress.

    Good luck!

    Mike

  3. Thanks for the pointers!

    Just wanted to mention that your command to restart the Apache server is incorrect (looks like you pasted the symlink command by accident).

    You can use either: apachectl2 restart or /etc/init.d/apache2 restart

  4. Thanks for the pointers!

    Just wanted to mention that your command to restart the Apache server is incorrect (looks like you pasted the symlink command by accident).

    You can use either: apache2ctl restart or /etc/init.d/apache2 restart

    edit: mistyped the apache2clt command

  5. Thank you SO much for this post!

    I’d been ripping my hair out trying to figure out why one of my servers was fine while the one I’m currently working with would not use .htaccess files! Turns out that the Rewrite module was available but not installed for some dumb reason and had it not been for you, I’m not sure I would have ever thought to look at it.

    Thanks again!

  6. Thanks a lot, this was a lifesaver – the procedure works on Maverick as well. Pretty sure I didn’t have that many problems with permalinks on my old Jaunty server, or perhaps I was using a better tutorial back then…

  7. Thanks! It did help me a LOT! 🙂

    To make it more difficult for me, I am new to PHP+Apache as well.

    Though I had enabled rewrite module by this – a2enmod rewrite
    I had to modify “000-default” from /etc/apache2/sites-enabled to get this working as per your instructions here.

    AllowOverride All –> That was all needed and finally find here. Thanks a lot for your post.

  8. Thanks man! Just went through backing up an exploded WP multisite database and repairing what I could from a raw file backup, rebuilding the sitemeta table from scratch because it was gone and moving everything to a new server and ran into this weird issue, but you saved my site.

  9. Thanks “AllowOverride All” worked a treat however I did this on the sites-available > default file instead of sites-enabled > 000-default.

    Does anyone know if there are any implications in doing this? What’s the difference between “sites available” & “sites-enabled”?? Thanks

  10. hi. thanks for the article. i have a problem cause i dont want to put wordpress permalink rules in .htaccess file. i want them to go directly in apace2.conf config file. everything goes well and pages display as supposed to. only problem is with files that have a .css or .php extension (which are basically the style sheets, images, and the comment post php file). what can i do to correct the problem

    heres what i have inside the block :

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

    any suggestions?

  11. Just want to say THANK YOU. I quite searched for a couple of hours and could not find any solution to my problem.. it was already driving me nuts.. until I found your posting.
    Again, thank you very much for sharing this important notice.

  12. Thanks for this… Ive been trying every trick in the book to get this working and this is the first post that I found that actually worked…

    Thanks for your help.

  13. Thank you so much for this. It’s really helped me getting Joomla and WordPress sites at working using SEO/User-friendly URLs working.

  14. Also worked on my Debian Squeeze server at home. Hardly surprising, given Ubuntu being based on Debian. Just thought I’d throw this into the mix if any debian users find their way here.

    Thanks again,
    Tris

  15. Thank you very much! I got it working my site working on Ubuntu 10.04. I would have never figured this one out on my own.

    One side note: Your code blocks are not working, so we have no idea what we are supposed to type into the terminal. Your code blocks have a bunch of garbled gibberish in them! You can delete this paragraph without offending me if you want, especially if you fix the code blocks.

    I was able to get it working by reading the rest of your post. I only needed to do three things:

    1. Create a symbolic link of the rewrite.load file from the /etc/apache2/mods-enabled /etc/apache2/mods-available directory.

    2. Modify the /etc/apache2/sites-enabled/000-default to say “AllowOverride All” in the section pertaining to my WordPress install directory.

    3. Restart the Apache2 webserver.

    Now to fix this on my other Ubuntu web server.

  16. Hi Alek
    Many thanks for pointing this out and sorry it has taken so long for me to correct. It was a long time ago I wrote this and possibly through upgrades and other changes to the blog those bits of code got corrupted .

    I must thank thanks Jon Corvin who has a copy of the post on his blog so I could just copy it back – http://joncorvin.com/category/linux/page/3/

    If anyone can see any other issues with the post or can add anything to it please comment.

    Thanks again

    Phil

Leave a Reply