(Ping! Zine Issue 21) – Subsequent to a prior article, Running Multiple Ruby on Rails Applications on One Domain, this new Rails article involves setting up Rails on your Windows system. This type of setup can allow you to either test your rails applications prior to deploying them to a Linux-based Rails host, or alternatively can allow you to serve Rails applications from your Windows server.
Baseline Installation of InstantRails
Installing Ruby and RoR on Windows is relatively seamless. Unlike Ruby and Rails on the Linux platform, there is a popular and frequently updated, fast-install, Instant Rails solution at http://instantrails.rubyforge.org/wiki/wiki.pl
This package contains not only Ruby, Ruby gems and Rails packages, but it also includes Apache, MySQL and even mongrel. Additionally, the package is self-contained and doesn’t modify your system variables.
This tutorial will go over the quick steps needed to add Ruby and RoR onto your Windows system using this Instant Rails package.
1. Go to http://instantrails.rubyforge.org/wiki/wiki.pl and click [Download], then select the most recent zip file. Opt to save it to your Windows system.
2. Unzip the saved file, either using Windows’ own unzipping tool, or your favorite zip utility, such as WinZip. Extract all the files into your main location (such as C:\).
Please ensure the location you have placed the rails files does not contain any spaces. An example acceptable path would be:
An example poor path selection would be:
C:\Documents and Settings\Owner\Desktop\InstantRails
Please note that the InstantRails directory will auto create as the files extract, so you do not need to create this folder.
3. Double click to open the InstantRails folder, then double click on the InstantRails.exe file to begin installation.
4. During setup, you will be prompted about changing the configuration path. Accept the suggested change.
Please note that if Apache or MySQL do not start upon installation, you should first try to kill whichever service is not running by clicking on the service button (Apache or MySQL) in the Instant Rails dialog box, then select kill in the list of options. You can then restart or start the service.
Setting up the two included applications (cookbook and Typo)
There are two applications included with InstantRails: cookbook and Typo. The instructions to set these up are as follows:
1. To run the cookbook and Typo applications, simply click the “I” button to the left of the Apache button in the Instant Rails dialog box. Then select Rails Applications > Manage Rails Applications.
2. Check the box to the left of cookbook and Typo, then select Configure Startup Mode. Determine what Runtime mode (development, test, or production) and what port (default is 3001) you wish to use. You may want to choose port 80 if you’ll be using Rails for all your production and development, since port 80 is the default port for http sites. This area provides instructions and links to files you will need to edit if you choose to use a port besides 3001 for development.
In our example, we will keep the default values, but select to Edit Windows HOSTS file. Once you select that option, add the following 2 lines to the bottom of it:
Select to save the file, then exit it by choosing X at the upper right corner of the file.
At this point, you will receive another prompt for production and it will show port 3002 as the default port instead. Simply select OK again.
3. Select the Start with Mongrel button back in the Rails Applications prompt. Since you have selected both cookbook and Typo, you will receive two command prompt windows that indicate mongrel and Rails are starting.
4. Open your browser and go to http://www.mycookbook.com to view the cookbook application. This is a pseudo site on your local system that you created when editing the Windows HOSTS file earlier. It doesn’t exist on the on-line world at this juncture; it is only a local site on the system.
5. To view the typo application, go to http://typo which will provide a signup page. Once you have signed up, this first user will be the administrator of the Typo application. Again, this is a site only available initially on your local system.
If you would like to serve the pages to the whole world, simply set it up to use any domain you already have serving pages on-line on your system. If you do not have this setup on your Windows computer, please ask your hosting provider on how to set this up if you do not already know how to do so. Most dedicated Windows hosting providers set up your primary domain for you, and will assist in configuring your new Rails environment to work with that domain upon request.
Please review documentation at http://instantrails.rubyforge.org/wiki/wiki.pl?Getting_Started for other details on what options are available for InstantRails installation.
Now, you can rock out with Rails on Windows! It’s easy and it’s free!