Thanks everybody. My goal was to setup a Ruby on Rails development environment on Windows XP allowing PHP and Rails to run side by side without clustering or proxying. Here’s my summary as to how I succeeded to setup the following development environment:
-
Windows XP
-
Xampp: Apache 2.0, PHP 5, MySQL 5
-
Ruby 1.8.5
-
Rails 1.1.6
-
Mongrel (gems: mongrel, mongrel_service)
Here’s how:
INSTALLATIONS
- First I installed XAMPP 1.5.0-pl1. I didn’t use the most recent version because of MySQL/Ruby compatibility Issues.
http://prdownloads.sourceforge.net/xampp/xampp-win32-1.5.0-pl1-installer.exe?download
- Ruby 1.8.5 - One click installer
http://www.ruby-lang.org/en/downloads
-
Rails: At the command line: gem install rails –include-dependencies. I used to have Ruby 1.8.2 installed and with the version of RubyGems that it came with the gem commands used to freeze. I know things still aren’t too stable with Ruby on Windows, but after I upgraded to 1.8.5 the gem command started working nicely.
-
Mongrel: gem install mongrel_service --include-dependencies. This will also install the mongrel gem. This gem will allow mongrel to run on Windows as a service.
CONFIGURATIONS
- Apache. Append the following to the httpd.conf file. Notice that I used mod_rewrite rather than mod_proxy to forward requests to mongrel. (If this is a no no, I have yet to find out!) I didn’t want to have to configure a mongrel cluster.
<VirtualHost *:80>
ServerName 127.0.0.1
DocumentRoot C:/path/to/rails/project
<Directory “C:/path/to/rails/project”>
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} -d
RewriteRule ^(.+[^/])$ $1/ [R]
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} .php
RewriteRule ^(.*)$ $1 [QSA,L]
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME}/index.html -f
RewriteRule ^(.*)$ $1/index.html [QSA,L]
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME}/index.php -f
RewriteRule ^(.*)$ $1/index.php [QSA,L]
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} -d
RewriteRule ^(.*)[^/]$ $1/ [QSA,L]
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ http://127.0.0.1:4000%{REQUEST_URI} [P,QSA,L]
- Mongrel. This is a one-time command to run at the command prompt to install a mongrel service that will serve your rails application:
mongrel_rails service::install -N [name_of_service] -c [c:\path\to\rails\project] -p 4000 -e [development]
[name_of_service] - name of the Mongrel Windows service that will serve the rails project.
[c:\path\to\rails\project] - as it says.
[development] - this can be either ‘development’ or ‘production’. As you can guess, running on Windows with XAMPP, I was running a development environment.
- Rails. Configure your development database in [c:\path\to\rails\project]\config\database.yml.
INITIATIONS
-
Command line: mongrel_rails service::start -N [name_of_service]
-
Start Apache+MySQL with XAMPP Control Panel.
-
Go to 127.0.0.1 in your browser.
RESOURCES
Local Development Environment
http://www.ridaalbarazi.com/blog/2006/06/21/local-development-environment-part-3/
Faster Is Possible (Official mongrel documentation - mongrel.rubyforge.org)
http://mongrel.rubyforge.org/docs/apache.html
Ruby On Rails List (Thanks Phillip)
http://groups.google.com/group/rubyonrails-talk/msg/99b36051504f783f
Let me know if I’ve left anything out. I hope this thread will help newcomers overcome the difficulties of setting up Rails on Windows for the first time!
Best,
Shimon Amit