2

I just finished a fresh install of Ubuntu Server and selected the LAMP package by default.

Tested it and it's working great with PHP scripts, but now I want to be able to run RubyOnRails on the same Apache install.

How can I accomplish this through the CLI?

Thanks a lot!

1
  • Why do you want Rails to use Apache. Rails has a built-in webserver. Jan 19, 2011 at 15:42

3 Answers 3

2

I would definitely use Passenger for this. It's easy to set up and run, and performs well. Passenger takes care of spawning and killing child Rails processes to handle incoming requests.

The passenger module supplied by Ubuntu is ok, but slightly behind. A more recent package is available by installing from the semi-official repository. According to Passenger's install page:

Add the following line to the Third Party Software Sources:

deb http://apt.brightbox.net lucid main

(The simplest way to do that is to create a file in /etc/apt/sources.list.d/ containing the deb instruction, and then run 'apt-get update').

Once you've done this then you can install Phusion Passenger by running:

apt-get install libapache2-mod-passenger

I think the installer automatically enables the module and restarts Apache, but if not you should do that yourself.

Check the manual on how to deploy a Rails app, but you'll find it remarkably easy:

<VirtualHost *:80>
    ServerName www.mycook.com
    DocumentRoot /webapps/mycook/public
    <Directory /webapps/mycook/public>
        Allow from all
        Options -MultiViews
    </Directory>
</VirtualHost>

I would also advise you to look at running Ruby Enterprise Edition (ree) which is a modified Ruby interpreter, built by the same team as Passenger, that features reduced memory usage by about 33%. It's well tested and 100% compatible with Ruby 1.8.7. You'll find many people running it on production servers.

1
1

You need use the passenger gem or you can use mod_proxy to do a proxy to your backend in Rails. In this cas you can run Rails with thin or unicorn.

1
  • Puuh that sounds complicated. Do you mind splitting it up a bit more to explain how it works?
    – Industrial
    Jan 19, 2011 at 14:34
1

Rails on Ubuntu as a Standalone HTTP server

Surprisingly there are not a lot of good looking HOWTOs on this.

Among the list that shows up on Google probably only the top item is good: http://www.google.com/search?q=rails+on+ubuntu+10.10

  1. Ruby on Rails 3 and MySQL on Ubuntu 10.10

Other items deal with RVM - I haven't used it and it seems unnecessarily if you have Gems.

With Apache

If you need it to run through Apache then you need to use Passenger - when you click on Install Passenger Now there is a nice HOWTO for setting up Apache mod_rails via Gems.

The official Rails deployment page lists Passenger as their first option (aka mod_rails): http://rubyonrails.org/deploy

1
  • The whole idea of running Ruby on Apache is being able to use both Ruby & PHP at the same staging server. I assume that following the article will cause havoc with both programs trying to check requests at port 80 / localhost?
    – Industrial
    Jan 19, 2011 at 17:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .