Getting WordPress, mod_rewrite and Leopard to work together
I’ve been trying to get Leopard, Apache 2 and WordPress working together for a while now. I want to use the WordPress friendly URL feature, and this requires the Apache mod_rewrite module to work too. There are various places around the web that have partial solutions to these problems. Here’s the procedure I followed – YMMV
First off, WordPress is installed in /Users/jameshiggs/Sites/blog. Leopard comes with Apache 2.2 installed, but has PHP disabled by default. To correct this, go to the console and change directory to /etc/apache2 and open httpd.conf in your favourite editor. For me this means typing:
sudo mate httpd.conf
You’ll probably have to enter your admin password. Find the line that reads:
#LoadModule php5_module libexec/apache2/libphp5.so
and uncomment it so that it looks like this:
LoadModule php5_module libexec/apache2/libphp5.so
Next, we need to make sure that your user directory allows .htaccess rules. To do this, create a file called jameshiggs.conf (obviously, you’ll need to replace my user name with yours) in /etc/apache2/users. The contents of that file should read:
<Directory "/Users/jameshiggs/Sites"> Options Indexes MultiViews AllowOverride All Order allow,deny Allow from all </Directory>
Again, you’ll need to replace my user name with yours.
The final piece of the jigsaw is to configure WordPress to use friendly URLs – which you do from the Options > Permalinks page. I’ve selected the second option which makes URLs look like this: http://localhost/~jameshiggs/blog/2007/12/25/sample-post/. If WordPress can write to the site root then it will automatically create the .htaccess file. If not, you’ll need to create it yourself in the root of your blog site. On my machine, the file should look like this:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /~jameshiggs/blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /~jameshiggs/blog/index.php [L]
</IfModule>
Finally, you need to restart Apache – the easiest way to do that is to go to System Preferences > Sharing panel and untick Web Sharing. Once Apache has stopped, tick it again and Apache should start up. And that’s it.
Let me know if you have any variants to this procedure.
Thanks to Bagelturf and Ariadoss for hints that helped me get this running.
Comments
3 Responses to “Getting WordPress, mod_rewrite and Leopard to work together”
Leave a Reply

You blogged on christmas day!! You have a problem my friend! Then again I read it so we’re both in trouble. Happy Xmas.
Not just blogged on Christmas day, but blogged about trying to get Wordpress to work on Christmas Day. Come on now James, step away from the keyboard. You don’t want to hurt anyone.
i’ll just give it a try first
thanks for the info ^_^