I have written a few Rails applications, but I couldn't have implemented anything useful for my day-to-day use. At least one of these applications I wrote seems usable, but I found Rails app deployment was the blocking factor.
I wrote a very simple app and just focused on Rails app deployment today. It turned out that there are enough things to overcome and that's why I couldn't complete my projects.
Picking a production configuration
It is nice for Rails to have easy-to-use application servers such as Mongrel or Webrick. For a low traffic site like mine, it should be okay in terms of performance. However, I have existing python CGIs and contents may not run.
I need to create a hybrid envornment to serve both legacy CGIs and new Rails apps.
There are a bunch of possibilities, and I picked apache +
Phusion Passenger because 1) the existing site runs apache and 2) it seems to be one of the good choices in 2008-2009.
Phusion Passenger installation on Gentoo Linux
Installation of Phusion Passenger was simple, but apache configuration was not. This is not Passenger's fault by the way.
Passenger is an Apache loadable module. Apache needs to load it when it starts. Gentoo Linux stores module configurations in
/etc/apache2/modules.d
(not
/etc/modules.d
!). I created
/etc/apache2/99_passenger_gaku_net.conf
I had a couple of erros here and here's how I debugged.
- I had wrong PassengerRuby path. Passenger didn't spit error. Just type the Ruby path and make sure it runs a Ruby interpretor.
- Use PassengerLogLevel directive for debugging.
PassengerLogLevel 1
- I enabled Apache's /server-info handler by opening it up to everyone temporalily. To do this, modify /etc/apache2/modules.d/00_mod_info.conf. Then, http://www.gaku.net/server-info shows useful info on Apache, and it should have mod_passenger.c in the page when the module was properly loaded. (/server-info is turned off now).
Installing a Rails app
As I have existing content on my site, I decided to give
/isbn
to my test Rails app. Other URI will be served by existing configuration.
It can be achieved by adding a following line in my vhost configution in
/etc/apache2/vhost.d/
.
RailsBaseURI /isbn
The filesystem directory
/web/isbn
needs to point the Rails app's public directory. I created a symboic link from my web directory.
My error here was using a wrong directive. There is
RukeBaseURI
. I needed to use
RailsBaseURI
.
No comments:
Post a Comment