Enabling mod_rewrite in Apache

03/20/2010 in Technology

This post is a bit geekier than usual but I have to share it because it’s something that was a bit frustrating until it was resolved.

I built a simple LAMP server at Linode this week and was testing out a WordPress site on it. Everything worked fine aside from the links, which was more than a minor frustration. My custom permalink structure is as follows:

I have the same permalink structure on my other servers. Nothing crazy.

My /var/www/ directives were as follows:

Options -Indexes +FollowSymLinks -MultiViews
AllowOverride None
Order allow,deny
allow from all

So that wasn’t the issue. My .htaccess file was in place:

# BEGIN WordPress

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

# END WordPress

My /var/www/ directory was chowned to www-data:www-data as well.

Still no dice. As it turned out (yes, I’m intentionally skipping over the weeping and gnashing of teeth), mod_rewrite (the Apache module responsible for URL rewriting) wasn’t enabled.

The fix? Running these commands:

# a2enmod rewrite
Enabling module rewrite.
Run '/etc/init.d/apache2 restart' to activate new configuration!
# /etc/init.d/apache2 reload
Reloading web server config: apache2.

That’s it! My “pretty” permalinks now work on the server. Whew.

{ 2 comments }

Joshua Chase March 20, 2010 at 10:23 am

Yup, that modrewrite will get you everytime!
How do you like linode? We’ve been using Slicehost, and Fivebean for all our hosting. I’ve heard good thingsa about Linode though!

Good tip, anyone who build wordpress on LAMP VPS servers need to bookmark this article!

Willie Jackson March 20, 2010 at 12:52 pm

Linode is fantastic, and I’ve been very pleased. Regardless of who you lease your VPSes through, the Linode Library is a fantastic resource for anyone looking to get their hands dirty.

Support is fantastic and I haven’t experienced even a second of downtime. Strongly recommended.