Getting Rails to Work on a Windows Machine Running Xampp

Ruby on Rails logo

Wow… so I wrote a post on my struggles getting Rails to work on my Windows Machine, and then I figured 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.

Note: This post was updated from my writings here… There may be comments there that can help you if you are struggling with this issue.

Enhanced by Zemanta

9 thoughts on “Getting Rails to Work on a Windows Machine Running Xampp”

  1. You have done a great job for posting this tutorial thanks for that, but I found two correction kindly update your blog.

    Step4: Create a rails app

    rails C:/xampp/htdocs/
    you have missed keyword new, Correct code
    rails new C:/xampp/htdocs/

    Step5: Configure Apache
    It is not working
    DocumentRoot “c:/xampp/htdocs//public”
    <Directory "c:/xampp/htdocs//public/”>

    I have replaced forward slash / with backward slash \
    and it work fine for me..
    DocumentRoot “c:\xampp\htdocs\\public”
    <Directory "c:\xampp\htdocs\\public\”>

    My conf.. Windows7 64bit, apache 1.7.4

  2. hello,
    sir here above all procees we do.and http://localhost:3000/ is worked. i am happy. but after we click About your application’s environment this link then error shows on webpage error 404. please teel me soon .
    thank you

  3. i tried replacing forward slash / with backward slash \
    DocumentRoot “c:\xampp\htdocs\\public”

    but Configure Apache will still not work.

    also
    in xampp when i name my files .cgi, the browser outputs
    but when i name my files .pl i get a Error 500

    why is this?

  4. Pingback: Internet Marketing
  5. Thanks a bunch! I’m new to RoR and your site just saved me a lot of headache! I’ve managed to get to the welcome page. However, when I click on the “About your environment link” I get the following error. Ruby on Rails: Not Found. The requested URL /rails/info/properties was not found

    Any clue?

  6. Hi.
    I am very new with ROR and just trying to setup with xampp.I followed your all steps you described step by step and configured ruby on rails successfully with xampp.
    But when i went to browser and just type http://localhost:3000/ it displays

    Access forbidden!

    You don’t have permission to access the requested directory. There is either no index document or the directory is read-protected.

    If you think this is a server error, please contact the webmaster.
    Error 403
    localhost
    Apache/2.4.4 (Win32) OpenSSL/0.9.8y PHP/5.4.16

    Could you please tell what went wrong with me.

    Thanks in advance.

  7. I cannot see how it works.

    Rails Server runs Webrick and listen at port 3000.

    Apache virtual host also listen at port 3000.

    I believe that the mod passenger should be enable to allow to ruby to work.

    Regards.

    hlkn

Comments are closed.