views:

821

answers:

5

Is is possible to install Ruby on Rails alongside WampServer (and keep WampServer's Apache/MySQL installs)?

A: 

This document walks you through installing RoR on WampServer.

mopoke
I've tried it but it is out dated. Ruby For Apache is no longer supported.
Olivier Lalonde
+1  A: 

Yes, There is InstantRails

S.Mark
Doesn't InstantRails install Apache and MySQL as well ? I wouldn't want to keep 2 different installs of Apache and MySQL.
Olivier Lalonde
I meant for easy installation and all-in-one standlone for Windows, Yes, Its just have everything like WAMP, or XAMPP.
S.Mark
A: 

This is assuming you're trying to set up a development environment, because it doesn't make much sense to use Windows and/or WAMP for a production server.

You can instally Ruby rather easily on Windows using the Ruby installer. There's also the one-click installer which includes a number of libraries (though you can install these yourself with rubygems later).

You are correct in that you install Rails (and dependencies) as a gem.

Now, as for Apache... I'm going to suggest that you keep your WAMP installation and simply don't use it for Ruby/Rails. Ruby has a built-in web server called WEBrick, and there's another light-weight server called Mongrel (available as a gem). These can be run simultaneously with Apache, with Apache serving PHP content and Mongrel/WEBrick serving Rails. They'll run on different ports (Apache on 80, Mongrel/WEBrick on 3000 by default), so there shouldn't be any conflicts.

There are several advantages with this approach:

  1. You won't have to mess with your WAMP installation and risk screwing something up.
  2. Running applications from different languages separately protects them from each other. For example, if your Rails app crashes the server, it won't bring your PHP stuff down with it in case you're running both.
  3. Thirdly, most popular Rails IDEs (RubyMine, Aptana, etc) have built-in controls for both or one of the Mongrel and WEBrick servers. This means that you'll be able to start/stop/restart your server within the IDE, as well as display the output/logs. For Rails development in Windows, I recommend RubyMine.

MySQL is separate from Apache, so your Rails app will be able to access MySQL databases regardless of which server is serving its content. Naturally, you'll have to run at least the MySQL version of WAMP in order for it to work.

vonconrad
+1  A: 

I have finally installed Ruby on Rails alongside WampServer. Here is how to do it:

PS: Replace *C:\wamp* in the following text by your own WampServer's install repertory.

Installing Ruby

  1. Download Ruby (the Windows binary version, not the "one click installer" because it contains MySQL and Apache which we don't need).

  2. Extract the zip to C:\wamp\ruby\

  3. Add Ruby's bin repertory in your PATH environment variable:

    • Right click "Computer / Properties".
    • Click "Advanced System Settings".
    • Advanced tab / Environment Variables.
    • Append ;C:\wamp\ruby\bin to the Path variable.

Installing Rails and the Mongrel server

  1. Open the command line and type:

    gem install rails

  2. Create your first Rails app. by opening the command line from C:\wamp\www\rails\ and typing:

    rails hello

  3. Install the Mongrel server and Windows Mongrel service (make sure to run the command line as administrator):

    gem install mongrel and gem install mongrel_service

  4. Install a Windows service for your Rails app.:

    mongrel_rails service::install -N ruby-hello -c c:\wamp\www\rails\hello -p 3001 -e development

  5. Start your Mongrel service:

    net start ruby-hello

    You can now access your Rails app. at http://localhost:3001/

Integrating with Apache

  1. Enable mod_proxy in httpd.conf

    Open httpd.conf (c:\wamp\bin\apache\Apache2.x.x\conf\httpd.conf) and uncomment the following line:

    LoadModule proxy_module modules/mod_proxy.so

  2. Forward your traffic to your Mongrel server. Add the following text to your httpd.conf (or extra/httpd-vhosts.conf if its included in your httpd.conf):

    <VirtualHost *:80>
    ServerName hello.com
    ServerAlias *.hello.com
    ProxyPass / http://localhost:3001/
    ProxyPassReverse / http://localhost:3001
    </VirtualHost>
    
  3. Add hello.com to your hosts file:

    Open c:\windows\system32\drivers\etc\hosts in Notepad and add the following line: 127.0.0.1 www.hello.com hello.com

You can now go to www.hello.com and it should load your Rails app !

References

Olivier Lalonde
A: 

Hi vonconrad,

Would you be able to outline the steps of creating a production environment for a ruby/rails app that has php components please? I understand that rails has its built in webserver.

I have my rails app running fine at localhost:3000 - but my php portion will not run properly, ive set it up with wamp < but im probably doing something wrong.

so if you are able to assist by providing clear steps - i would be greatly thankful and follow them.

thanks in advance. ak/

akza