Monthly Archives: March 2010

Riding Rails on Ruby Enterprise Edition

Passenger allows Ruby on Rails applications to use about 33% less memory, when used in combination with Ruby Enterprise Edition

I am putting down steps to install Ruby Enterprise Edition and configure Passenger to use Ruby Enterprise Edition

Download Ruby Enterprise Edition

You can download Ruby Enterprise Edition here.

Or through terminal,

wget http://rubyforge.org/frs/download.php/68719/ruby-enterprise-X.X.X-YYYY.MM.tar.gz

Install Ruby Enterprise Edition

Extract the files:

tar -xvzf ruby-enterprise-X.X.X.tar.gz

Run the installer. As root,

./ruby-enterprise-X.X.X/installer

Set the path environment variable:

vim ~/.bash_profile

Add the following line:

export PATH=/opt/ruby-enterprise-X.X.X-YYYY.MM/bin:$PATH

Load the path environment variable in the current session:

As root,

source ~/.bash_profile

That’s it, we are done installing Ruby Enterprise Edition.

You can verify by:

ruby -v

ruby 1.8.7 (2009-12-24 patchlevel 248) [x86_64-linux], MBARI 0x6770, Ruby Enterprise Edition 2010.01

DO remember that this is a fresh installation of Ruby, that implies, you need to install all the necessary gems again. Ruby Enterprise Edition by default installs the latest stable version of Rails and the Passenger gem as well.

Now you can install and configure the Passenger module for Apache as described in article found at https://adhirajrankhambe.wordpress.com/2010/03/20/riding-rails-the-php-way/.

References:

http://www.rubyenterpriseedition.com/
http://www.rubyenterpriseedition.com/documentation.html

Add to FacebookAdd to DiggAdd to Del.icio.usAdd to StumbleuponAdd to RedditAdd to BlinklistAdd to TwitterAdd to TechnoratiAdd to Yahoo BuzzAdd to Newsvine

Leave a comment

Filed under Ruby, Ruby on Rails

Riding Rails the PHP way

I have been working with PHP for quite some time now, though my first love has always been Ruby on Rails :)

While working with PHP, I realized that deployment of a PHP application is far more easier as compared to deployment of a Ruby on Rails application. So I was wondering if there could be a way to deploy a Ruby on Rails application in a similar fashion, as easy as you check out the Rails project in a directory on the server, configure a VirtualHost in the webserver, restart the webserver and there you go, everything should work as expected.

Luckily I did find a saviour,

“Phusion Passenger” a.k.a “mod_rails” or “mod_rack”

Here I am putting down steps to ride Rails on Passenger.

Install Passenger

Passenger is available as a Rubygem. As root,

gem install passenger

Install Passenger module for Apache

passenger-install-apache2-module

During installation it will prompt:

The Apache2 module was successfully installed.

Please edit your Apache configuration file, and add these lines:

LoadModule passenger_module /usr/lib64/ruby/gems/1.8/gems/passenger-2.2.11/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib64/ruby/gems/1.8/gems/passenger-2.2.11
PassengerRuby /usr/bin/ruby

NOTE: Do NOT copy-paste from here. Make sure you add the lines that passenger prompts you with.
It is specific to the OS installation. Mine was a Fedora Core 10 64-bit installation.

Next, it will help you to configure a VirtualHost for Apache

<VirtualHost *:80>
  ServerName www.yourhost.com
  DocumentRoot /somewhere/public

    <Directory /somewhere/public>
      AllowOverride all
      Options -MultiViews
    </Directory>

</VirtualHost>

Restart Apache:

As root,

/sbin/service httpd restart

That's it, we are done.
Point your browser to your domain, and you should be able to see your Ruby on Rails Application.

Do keep in mind that the default Rails environment while using Passenger is “production”
To access your application in “development” or any other environment add the following line in your VirtualHost configuration:

RailsEnv development

Restarting your application deployed in production environment:

To restart your Rails application deployed in production environment you can restart Apache.
But that's not a good solution if you are hosting multiple applications on the same server, or even generally, it doesn't sound like a good idea to restart Apache every now and then.
To overcome that, you can restart your application in the following way:

From Rails Root Directory,

touch tmp/restart.txt

That's it, this will restart you Rails application.

The best part is, Passenger is compatible with all the Rubygems and Rails plugins.

So nothing should break. I personally tried running a complex Rails application that uses Solr as the search engine along with acts_as_solr plugin, backgroundRB server for background processes, attachment_fu for file uploads etc, etc.

Everything worked like a charm.

For further configuration, please refer to the Passenger documentation found here:

You can also use Passenger to serve Non-Rails Ruby web applications. That can be a good alternative to the already prevalent mod_ruby module for Apache.
If you are using Nginx as your webserver, you can use Passenger module for Nginx.

There's just one disadvantage to Passenger:

It doesn't work on Windows. In any case, I personally never prefer to develop Rails (or any other) applications on Windows :)

Good news for Mac users:

fingertips has come up with an OS X preference pane for Phusion Passenger (a.k.a. mod_rails) that makes it a cinch to deploy Rails applications using Passenger on the Mac. It can be as simple as dragging a Rails application folder onto the preference pane! This is absolutely ideal for quick and easy Rails development on OS X.

You can download the Passenger Preference Pane here

References:

http://www.modrails.com/documentation/Users%20guide%20Apache.html

Add to FacebookAdd to DiggAdd to Del.icio.usAdd to StumbleuponAdd to RedditAdd to BlinklistAdd to TwitterAdd to TechnoratiAdd to Yahoo BuzzAdd to Newsvine

1 Comment

Filed under Ruby, Ruby on Rails