Deploying your Rails applications with Phusion Passenger
There have been several methods to deploy an Ruby on Rails application. Until recently, the most popular is to run Apache and proxy balance to multiple Mongrel instances that are running simultaneously.
Passenger, developed by Phusion, is the new kid entering the Rails deployment market. We have been using the Apache PHP module for years and deploying a PHP applications is a snap. This has not been possible with Rails until Passenger. It is so easy too! You can still use Capistrano to automate deployment. I will show you how I get it to work on Ubuntu.
sudo gem install passenger
passenger-install-apache2-moduleUpdate: Phusion just released Passenger 2.0 RC 1. You can download this version and do gem install passenger-1.9.0.gem instead. But I had an error compiling it on Mac OS X Leopard. hongli pointed me to use the version from GitHub that has the fix and it works like a charm. Thanks Phusion guys.
To get it from GitHub:
git clone git://github.com/FooBarWidget/passenger.gitI create a separate /etc/apache2/mods-available/passenger.load and it contains the following:
For 1.0.5:
LoadModule passenger_module /usr/local/lib/ruby/gems/1.8/gems/passenger-1.0.5/ext/apache2/mod_passenger.so
RailsSpawnServer /usr/local/lib/ruby/gems/1.8/gems/passenger-1.0.5/bin/passenger-spawn-server
RailsRuby /usr/local/bin/rubyFor the GitHub version (Of course the path will look different depending on where your git clone is):
LoadModule passenger_module /home/rlaw/downloads/passenger/ext/apache2/mod_passenger.so
PassengerRoot /home/rlaw/downloads/passenger
PassengerRuby /usr/local/bin/rubyI then tell Apache to load the Passenger module:
a2enmod passengerNow, I create a virtual host configuration for one of my Rails app in /etc/apache2/sites-available/dealistic:
<VirtualHost *:80>
ServerAdmin webmaster@dealistic.com
ServerName dealistic.com
DocumentRoot /home/deploy/apps/dealistic/current/public
<Directory /home/deploy/apps/dealistic/current/public>
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
LogLevel warn
ErrorLog /var/log/apache2/dealistic/error.log
CustomLog /var/log/apache2/dealistic/access.log combined
</VirtualHost>I then restart Apache:
sudo /etc/init.d/apache2 reloadWhen you need to restart your application because you have changed some code that Rails does not reload in production, just do:
touch /home/deploy/apps/dealistic/current/tmp/restart.txtI have not tried their Ruby Enterprise Edition yet. They claim substantial memory and speed improvement at RailsConf 2008, so it will be interesting to see.
Badger Rails Plugin
(I also posted about this plugin in the Intridea blog )
Badger (hosted at GitHub) is a simple Rails plugin that creates badges. A site often allows its users to upload a profile image. A profile image is just that, an image resized to fit in a predefined space to show up in the user’s profile.
With Badger, you can have something prettier – a badge that shows the user-uploaded image on top of another image that identifies the user as a part of the community. We have company badges, security badges, so why not web badges to have your users show off his/her affection for your site?
Badger works by accepting cropping parameters of the overlay image in a hash (x1, y1, width, height), which is used to crop the overlay image. It then resizes the cropped image to the size specified by composite_width and composite_height in badger.yml. Finally, it places the resized image on top of the background image at location specified by composite_x and composite_y in badger.yml. The resulting image is saved back to either the filesystem or Amazon S3, using attachment_fu.
Badger requires the attachment_fu plugin, ImageMagick, and MiniMagick. Also, the JavaScript Image Cropper UI can be used to obtain the cropping parameters from the users.
For example:
+
=

Here I overlay RUBY on top of JAVA to produce I LOVE RUBY.
Installing Sphinx on Mac OS X Leopard
Download the latest release from http://www.sphinxsearch.com/downloads.html
The usual
./configure
make
make installgives me an error:
g++ -Wall -g -D_FILE_OFFSET_BITS=64 -O3 -DNDEBUG -o indexer indexer.o libsphinx.a -L/opt/local/lib -L/opt/local/lib/mysql5/mysql -lmysqlclient -L/opt/local/lib -lz -lm -L/opt/local/lib -lssl -lcrypto -liconv -lexpat -L/usr/local/lib
Undefined symbols:
"_iconv_close", referenced from:
xmlUnknownEncoding(void*, char const*, XML_Encoding*)in libsphinx.a(sphinx.o)
"_iconv", referenced from:
xmlUnknownEncoding(void*, char const*, XML_Encoding*)in libsphinx.a(sphinx.o)
"_iconv_open", referenced from:
xmlUnknownEncoding(void*, char const*, XML_Encoding*)in libsphinx.a(sphinx.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[2]: *** [indexer] Error 1
make[1]: *** [all] Error 2
make: *** [all-recursive] Error 1These two articles detail how you can resolve the error:
Back from RailsConf 2008
Photos posted to my flickr.


