OK, this is not about the details of how to install mod_rails on leopard, actually the process is pretty straightforward and there are already some good document on mod_rails’ website . Well, the confusing part of using mod_rails+apache on leopard is that you have to know how the default apache coming with leopard works. 

This is what I did after I installed mod_rails and copied those three lines to the httpd.conf

  1. Uncomment line 464: Include /private/etc/apache2/extra/httpd-vhosts.conf to enable the virtual host
  2. add apps.conf under /etc/apache2/other , I will place all local app that I would like to use mod_rails here
    <VirtualHost *:80>
    ServerName test.local
    DocumentRoot /Users/snow/Sites/test/public
    RailsEnv development
    </VirtualHost>
  3. adding virtual host in /etc/hosts : 127.0.0.1 localhost test.local
  4. now restart the apache, open the browser and visit redmin.local/images/logo_snap.jpg(some file I copied) and here comes the problem
  5. Forbidden

    You don’t have permission to access /images/logo_snap.jpg on this server.

After googling for a while and doing some test, I figured out the reason:

  1. If you use the default apache coming with leopard, the only places you will place your site folder should be ~/Sites . Virtual hosts whose document root are somewhere other than ~/Sites will not be able to start properly and apache will throw the Forbidden page like above. But for me, I have another place to store my rails project (~/workspace) and I would not like to copy my file to ~/Sites every time so the first choice would be create symbolic links.
  2. By default, the username.conf(in my case, snow.conf) under /etc/apache2/users looks like this by default:
  3. <Directory “/Users/snow/Sites/”>
        Options Indexes MultiViews
        AllowOverride None
        Order deny,allow
        Allow from all
    </Directory>
    In order to let symbolic links work properly, I changed my snow.conf file to 
    <Directory “/Users/snow/Sites/”>
        Options Indexes MultiViews FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
    If you don’t add FollowSymLinks in options, you will still get the permission error page.
  4. Ok, now I see my app working properly in my browser after typing http://test.local