Rails Setup

After creating the TriCities Baseball, I wroteup some instructions for people who want to download and install it on their computer for further development. These instructions are also useful for other Ruby on Rails installations.

General Setup

The config/database.yml and public/dispatch.* need to be customized for the environment, so these are not automatically installed when you do a checkout from svn. There are template database.yml files in config to get you started, and template dispatch.* in public.

.htaccess

The public/.htaccess file needs to have the rewrite base pointing to the correct directory. So change the following line as necessary:

RewriteBase /store

Directory Permissions

On Windows, you don’t need to worry about any directory permissions. On Linux, Apache needs to write into the tmp/sessions and log directories. So it is best to change the group of these directories to “apache” (or whatever group the Apache server runs under) like this:

chgrp apache tmp/sessions
chgrp apache log
rm log/*.log

Symlink/Alias Background

On a linux server, there is a symlink in httpdocs called ??store? that links to the Rails store/public directory. Since Windows doesn??t support links very well (Windows ??.lnk? files are not recognized by Apache, and Windows junction points are more like hardlinks which causes other problems with Rails), it seems easiest to create an alias in the httpd.conf file.

Linux Setup

Create a symlink named “store” in the DocumentRoot pointing to store/public.

Windows Apache2 Setup

Setup Apache2 on Windows, then make the following changes:

c:\Program Files\Apache Group\Apache2\conf\httpd.conf

#MD Default is 250 which is not needed for local test
ThreadsPerChild 25

#MD Include the rewrite module
LoadModule rewrite_module modules/mod_rewrite.so

#MD Add index.htm to the default list
DirectoryIndex index.htm index.html

<Directory />
    Options FollowSymLinks
    #MD Was ??None? but this seems to also prevent changing AllowOverride later, so change this to ??All?
    AllowOverride All
</Directory>

#MD Uncomment this
NameVirtualHost *:80

#MD Add to the bottom of the file the virtual hosts section including the ??/store? alias, something like this:
<VirtualHost *:80>
    ServerName maxdunn.us
    DocumentRoot "/webs/TriCities/html" 
    <Directory "/webs/html">
        Order allow,deny
        Allow from all
    </Directory>
     Alias /store "/webs/TriCities/store/public" 
    <Directory "/webs/public">
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

Hosts

c:\WINDOWS\system32\drivers\etc\hosts

#MD Add something similar so the virtual hosts will work
127.0.0.1    maxdunn.us