Couple months back when I just started programming on Ruby on Rails, I faced so many problems regarding the configuration and all, in my developing machine Vista. I searched so many resources online but didn’t find a suitable one. Now I managed to resolve that problem. So, I would like to share the knowledge to you on how to setup Rails on Windows platform, using Ruby gems, Rails, Mongrel, and MySQL as a part of the stack. I am using windows Vista for my development process, but all the instructions will work in the Windows Xp too.
1. Installing Ruby: Download and install the latest version of Ruby Installer (currently 1.8.6-27 RC2) from the rubyforge.org website: One-Click Ruby Installer. Leave all the default settings during installations as such. Its important that you install in the ruby path without any spaces in it. (Like C:/Ruby by default).
After the installation go to the command prompt in the system (Start –> Accessories -> Command Prompt), and type the following command:
|C:\Users\Mikx>ruby -v ruby 1.8.6 (2008-08-11 patchlevel 287) [i386-mswin32]|
2. Updating Ruby Gems: The above installer also install Gems package via the one-click Installation process. May be the Gem installed will be outdate, so in order to avoid such errors, we should update the Gem package. To do so enter the following commands in the command-line:
|C:\ Users\Mikx> gem update ––system C:\Users\Mikx>gem -v 1.3.3|
3. Installing Rails: Now its the time to install Rails package. Run the following commands to install Rails package as Ruby Gems.
|C:\> gem install rails C:\Users\Mikx> rails -v Rails 2.3.2|
In future if you want to upgrade the Rails Gem, just simply run the following commands
|C:\Users\Mikx> gem update rails|
The basic Rails environment is now installed on your system, and you can skip the following part if you are happy with WEBrick as the web server, SQLite as the database server.
The remaining part of the post covers an alternate Web Server called Mongrel, and MySQL Database.
4. Installing Mongrel: Another most recommended Web Server for Rails development and also for production Server is Mongrel . To install Mongrel Web Server, run the following commands:
|C:\Users\Mikx> gem install mongrel C:\Users\Mikx> gem list mongrel *** LOCAL GEMS *** mongrel (1.1.5)|
After installing Mongrel, Rails automatically starts the Mongrel instead of WEBrick web server when you run the Rails applications in development mode.
5. Installing MySQL: This step covers the installation of MySQL database server and its GUI tools, if you need some other databases, just skip this step.
Download and install the MySQL 5.1 database server. You can safely accept all the default settings of the installation wizard. After MySQL database server is installed, you need to run its configuration wizard to configure the MySQL installation.
One important step during the configuration process is to select a root password(you will need to enter it in the database.yml configuration file of your Rails application).
Now download and install the MySQL GUI tools.
Now you can create/checkout rails applications, edit them and run them under Mongrel. In the next series I will explain how to create a basic “Hello World” application in Rails.