Getting Rails to Work on a Windows Machine Running Xampp
Wow… so I wrote a post on my struggles getting Rails to work on my Windows Machine, and then I figure it out. I’ve been developing in various languages, and using Xampp to for my server, database, and programming language (Apache, MySQL, PHP). Nevertheless, I have finally got it working, and it was a lot simpler than I had figured. In case you’ve come here and you’re yet to get Xampp… I’ll walk you through the whole process. If you already have it, then go ahead and skip to STEP 2
STEP 1 – Install Xampp – ApacheFriends has made it really easy by giving us a simple windows installer to download. If your interested in developing with Perl, Tomcat, you can download their Add-Ons by clicking the links. Once you download, just give it a click and follow the on-screen instructions. I recommend you install Xampp at the default c:\xampp (if you do not, remember to replace the code below with your installation directory). Here’s a video to show you how simple it is…don’t be fooled, it takes a little longer than the video shows.
STEP 2 – Install Ruby – Thanks to RubyForge, you can download an easy one-click Ruby installer to use here. Once you download, click to open, and follow the instructions. I recommend you install Ruby at c:\xampp\ruby so it falls in line with your other programming languages, etc…
STEP 3 – Install Rails – Fortunately, the Windows version of Ruby comes with RubyGems already set up. Open your Command Prompt (start-> run-> cmd -OR- start-> programs-> accessories -> command prompt) and type the following commands.
Do the gem update from the bin directory in rails. For my installation:
cd c:\ruby\bin
gem update
You may be prompted several times to choose which gem. Pick the highest version for (mswin32)
gem install rails --include-dependencies
There may be some delays, and the install could take a while. If you encounter an error trying to use the gem command, just restart the Command Prompt.
STEP 4 – Create a Rails App – While your still in Command Prompt, type the following Command (without the brackets, and change “your-app-name” to whatever you wish to call your application)
rails C:/xampp/htdocs/<your-app-name>
STEP 5 – Configure Apache – With your Xampp installation, http://localhost (localhost:80) defaults to the Xampp browser control panel, which displays your status, tests, etc.. We want to be able to use Ruby, without disrupting this service, or interfering with our standard Xampp settings. Open your Xampp directory (in our case C:\Xampp) and browse to Apache\conf\httpd.conf and open the httpd.conf file in a text editor or other text editor of your choice.
Scroll all the way to the bottom, and add the following:
Listen 3000
LoadModule rewrite_module modules/mod_rewrite.so
#################################
# RUBY SETUP
#################################
<virtualHost *:3000>
ServerName rails
DocumentRoot "c:/xampp/htdocs/<your-app-name>/public"
<Directory "c:/xampp/htdocs/<your-app-name>/public/">
Options ExecCGI FollowSymLinks
AllowOverride all
Allow from all
Order allow,deny
AddHandler cgi-script .cgi
AddHandler fastcgi-script .fcgi
</Directory>
</VirtualHost>
#################################
# RUBY SETUP
#################################
Finally – Check it Out – Point your browser to http://localhost:3000 and you should see the “Welcome Aboard” from ROR.
If your also looking for some editors. A nice simple free PHP editor with great extensions is “PSPad“. For hardcore coding, I recommend Zend(free for 30 days). For a nice simple free Rails Editor, “RoRED“, something a little more intense I would say go with the free “NetBeans” (don’t forget the .jdk).
Update 04/15/09
I now dual boot to Linux to play with ROR vs. fighting to install ruby on rails on a windows machine. I found it to be an endless battle of debugging.
Tags: linux, php, programming, rails, ror, ruby on rails, Technology, tutorialRelated posts
Posted in Technology | View Comments




[...] I finally got it working on Windows – check it out)[...]
Some comments for this post started popping up in a thread on another post.. if your having any problems you might want to also check here
thanks for the guideline..have some troubles while installing ruby with xampp..
a problem occured, after I add the the syntax in httpd.conf, and I restart the apache, it cannot runs well. then, i remove the syntax, apache runs well. how to solve it?
Sorry hafreze… I just went back over everything… there was a missing “>” at the end of the Directory line… /public/”>
If you copy and paste the info now, everything should work fine for you!
I got it working but am stuck in database selection with production, dev and test. I found one small mis-pointer in your blog post :
“Open your Xampp directory (in our case C:\Xampp) and browse to Apache -> httpd.conf and open the httpd.conf file in a text editor or other program editor of your choice.”
its should be \xampp_folder\apache\conf\httpd.conf file.
Geshan
@Geshan.. thanks for pointing that out… I’ll be sure to update the post.
If you are running Xampp, then you want to make sure you set the rails config for mysql database. You want multiple databases for prod. dev., and test… I just created for my 3.
after all, the configuration for rails in xampp is working..thanks jake. By the way, as what Geshan had stated, the default database for rails is sqllite3. I would like to use the mysql in xampp as my database, is it possible to do that?
@hafreze
Yes, in the new Ruby, its as easier as changing adapter: sqlite to adapter: mysql in the config/database.yml
oh really?!..I read at other forum in which they stated about the usage of socket..is it necessary? MYSQL_SOCKET_LOCATIONS = [ â€/tmp/mysql.sockâ€, #default â€/var/run/mysqld/mysqld.sockâ€, #debian/gentoo â€/var/tmp/mysql.sockâ€, # freebsd â€/opt/lampp/var/mysql/mysql.sockâ€, # xampp â€/var/lib/mysql/mysql.sock†, #fedora â€/Applications/xampp/xamppfiles/var/mysql/mysql.sockâ€] #xampp on osx
if needed, how could i correctly configure that?
ok..i figure out on how to change from sqllite 3 to mysql..we should change the config/database.yml file
# SQLite version 3.x
# gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
adapter: mysql
encoding: utf8
database: temp_development
username: root
password:
socket: /tmp/mysql.sock
# Warning: The database defined as ‘test’ will be erased and
# re-generated from your development database when you run ‘rake’.
# Do not set this db to the same as development or production.
test:
adapter: mysql
encoding: utf8
database: temp_test
username: root
password:
socket: /tmp/mysql.sock
production:
adapter: mysql
encoding: utf8
database: temp_production
username: root
password:
socket: /tmp/mysql.sock
after that, go to phpmyadmin and create database with the name of ‘temp_development’
hey you said to use Zend as a Ruby on Rails editor… but it doesnt pick up the files i think it’s specifically for PHP. How do i go about this ?
madd nubb!
-f00f
PHP: I was recommending Zend for the hardcore coding, and pspad for the simple editing.
Ruby: I was recommending Netbeans (don’t forget the jdk) for the more advanced ruby editing, and rored for simple ruby editing.
[...] on Rails I initially tried to install Ruby/Rails into XAMPP using this guide. The initial steams worked fine, but using gem to install rails wouldn’t work. Some googling [...]
[...] Getting Rails to Work on a Windows Machine Running Xampp [...]
Can you describe the performance difference? Is it much faster to use XAMPP than to use Webrick or Mongrel?
I’m not sure of a performance difference.. though if your interest is solely in running rails, and you aren’t concerned with php.. you’re best bet would be to go with webrick, and ignore xampp altogether.
Did your tutorial, but it does not work. I have got the “welcome aboard” screen (that is in html so that works) but XAMPP (Apache server) can not handle Ruby coding. Made a new controller and it could not found the page.
I get the ‘“Welcome Aboard” from ROR’, but I am not able to get the rails/info/properties. Any help is appreciated.
@Dick I’m having the same problem. I get the welcome aboard but hitting a test page (e.g. http://localhost:3000/say/hello) returns a 404, Object not found! error.
I cant able to run .rb file through this way , anybody can help me how to run .rb file on http://localhost:3000
[...] Install Xampp and Rails on a Windows Machine 在Xampp上安装Ruby (tags: Ruby) [...]
Hi
I have followed the above step but getting the following error when I goto http://localhost:3000 and explore the “About your application environment”
Object not found!
The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.
If you think this is a server error, please contact the webmaster.
Error 404
localhost
04/15/09 12:55:55
Apache/2.2.9 (Win32) DAV/2 mod_ssl/2.2.9 OpenSSL/0.9.8i mod_autoindex_color PHP/5.2.6
Thanks in advance.
Hi DMA.. sorry I did not update the post sooner. I gave up on using rails on a windows machine. I now do all of my rails work by dual booting to linux. It was definitely worth it!
Hello Jake, I have seen same instructions in other places, so this should work fine but why is not working I dunno. Is there anyone who has used in windows machine??
Jake. While I appreciate your attempt at trying to help windows users install RoR, I just spent over an hour installing and troubleshooting according to this guide, just to find you saying in Comment 24 that you “gave up”????
If this guide does not work, PLEASE TAKE IT DOWN. While u were doing a great service with good intentions, the fact that you’re misleading people is now a great disservice.
Hi Wow… while I understand your frustration, please note that the guide works for getting rails up and running to “Hello World”, but there are a ton of other issues that arise (as I’m sure you’ve discovered) once you start developing your app.. this is why there is a bold section in the post with the update that I no longer use rails in windows… in addition to comment 24.
Unable to connect http://localhost:3000 . I cannot connect to localhost. I put already
Listen 3000
LoadModule rewrite_module modules/mod_rewrite.so
#################################
# RUBY SETUP
#################################
ServerName rails
DocumentRoot “c:/xampp/htdocs//public”
<Directory "c:/xampp/htdocs//public/”>
Options ExecCGI FollowSymLinks
AllowOverride all
Allow from all
Order allow,deny
AddHandler cgi-script .cgi
AddHandler fastcgi-script .fcgi
#################################
# RUBY SETUP
#################################
Got this to work on Vista SP2 first time!
nice action
Hi, I just tried this and it was very helpful, thanks!
I removed the “<your-app-name>/public” and it works perfect for me.
Not working, the only thing that works is the “welcome abroad” page… this tutorial is FAKE