RapidWeaver Local Exports

RapidWeaver has an “Export Site...” menu item which lets you export your entire site to a local directory. That got me thinking – what if I could use the Mac OS X web server (which just happens to be Apache) to preview the site and test out tweaks to the theme CSS files? Turning on the web server is really easy:
  1. Go to System Preferences
  2. Select Sharing
  3. Click on the Web Sharing checkbox
That’s all there is to it. The contents of the Site folder in your user folder are used as the root of the website. To access your local web site, simply open Safari and type in http://localhost/~your_user_name - and voilà the default web page (index.html in Sites) comes up. In fact anyone on your local home network can access your website using Bonjour in Safari. What could be simpler!

The RapidWeaver theme I’m using for Free Range Coder is Unity 2.0 from NimbleHost. It’s a really nice simple theme which automagically adapts itself for the iPhone / iPod sized devices. It also uses PHP and the default configuration file for Apache in Snow Leopard does not have PHP enabled. I found this site which walks you through the configuration file changes for Apache and setting up the PHP initialisation file. In a nutshell:

To enable PHP in Apache - uncommenting the line below in /etc/apache2/httpd.conf:

LoadModule php5_module libexec/apache2/libphp5.so

Copying the default php.ini file from php.ini.default file in /etc:

cd /etc
sudo cp php.ini.default php.ini


The article goes on to show how to fix a warning in phpinfo() by setting the timezone in php.ini.

Back to RapidWeaver... So I dilligently exported the Free Range Coder website into frc in Sites within my Home directory. Launched Safari and typed in http://localhost/~kirschen/frc in Safari’s location bar and the page came up. But... It wasn’t what I had expected – the Unity theme style had not been applied.

And then I remembered what I had heard at the end of the Nosillacast Episode 301 - I’ll just check the Console Logs! I fired up Console (which we all know lives in the Utilities folder under Applications) and switched to All Logs. I typed in “apache” in the search bar in the upper right. And I saw bajillions (and that’s a technical term) of errors, all similar, one of which read:

[Sat Mar 05 12:43:41 2011] [error] [client ::1] (13)Permission denied: file permissions deny server access: /Users/kirschen/Sites/rw_common/themes/unity_v2.0/scripts/extracontent.js, referer: http://localhost/~kirschen/index.php

Aha! The plot thickens! This told me that some files were not readable by the Apache server, and where the files resided. Yes - the Unity theme. I whipped up a Terminal window and cd’ed over to /Users/kirschen/Sites/rw_common/themes/unity_v2.0 and listed the files therein using the ls -al command. The errant files had the same Unix permissions, an example – the one referenced in the Console Log – was:

-rw------- 1 kirschen staff 217 Mar 5 2009 extracontent.js

The rw indicated that the user (myself) had read and write permissions on the file, the dashes showed that members of my group (staff) and other users had no access permissions at all. So how does one fix permissions like this? No, you cannot use the Disk Utility “Repair Permissions” as Mac OS X knows nothing about what the correct permissions for these files should be. We’ll have to make the permissions changes ourselves from the Terminal. I could change the permissions in the frc directory but the next time an export was made from RapidWeaver, the Unity theme files would be overwritten and I’d be back changing permissions again. No, I had to make the change in the RapidWeaver theme directory. So, here are the steps from the Terminal:

cd “~/Library/Application Support/RapidWeaver” – This brings us to the RapidWeaver application support directory in which the Unity theme is installed

chmod -R go+r Unity-v2.0.rwtheme – The Unity theme shows up as a file in the Finder but it’s actually a file bundle. The chmod command will change the permissions so that the group (g) and others (o) get read permission (+r) and the -R option tells chmod to recursively go down the directory structure within the Unity-v2.0.rwtheme directory.

Re-exported the Free Range Coder site into frc – and it works as advertised! So now I can tweak the CSS files to my hearts content before committing the changes to the theme directly.