Update: passenger 2.2.5 release notes states that there are know issues with Snow Leopard, but developers didn’t had chance to test them out yet. I personally found no problems on 2.2.4. To upgrade simply run:
sudo gem install passenger
sudo passenger-install-apache2-module
and change apache config according to new version. Follow me on twitter for up to date info.
The installation works out as usual and it’s pretty straightforward, version 2.2.4 2.2.5 and using stock Apache which comes with Snow Leopard as default.
Install Xcode from Snow Leopard DVD, and it would be also wise to upgrade rubygems before doing this operation, search older posts.
Install the gem:
sudo gem install passenger
sudo passenger-install-apache2-module
sudo mate /etc/apache2/other/passenger.conf
passenger.conf doesn’t exists on a vanilla installation (of course), therefore create it or look below. I’m also using the “mate” command, which fires up TextMate, replace “mate ” with your preferred text editor, like vi, nano, etc.
If you want to use your personal configuration file instead of passenger.conf:
sudo mate /etc/apache2/users/username.conf
Replace username with your username in Snow Leopard.
Paste those lines in:
LoadModule passenger_module /Library/Ruby/Gems/1.8/gems/passenger-2.2.5/ext/apache2/mod_passenger.so
PassengerRoot /Library/Ruby/Gems/1.8/gems/passenger-2.2.5
PassengerRuby /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
RailsEnv development # or production, but anyway production it's the default value if you don't specify.
Now edit the main file:
sudo mate /etc/apache2/httpd.conf
Around line 465 you will find the commented line:
465
| #Include /private/etc/apache2/extra/httpd-vhosts.conf |
Remove the # and save the file, this will make Apache pickup extra vhost configuration file.
Open up your Control Panel, go into Shares (Condivisione in Italian), Web share, toggle the checkbox and leave it enabled to reboot Apache and let it pickup those changes.
I’m refraining from installing the complementary PassengerPane at this time since it still uses RubyCocoa instead of MacRuby and its last update is dated 2008, therefore open up:
sudo mate /etc/apache2/extra/httpd-vhosts.conf
and paste a similar code to deploy your rails application:
<Virtualhost *:80>
ServerName www.yourhost.com
DocumentRoot /somewhere/public # < -- be sure to point to 'public'!
</VirtualHost>
Reboot again Apache as described above, as an extra as usual you can edit /etc/hosts to add your ServerName mapped to 0.0.0.0 or 127.0.0.1 or what you prefer by writing a simple line:
127.0.0.1 www.yourhost.com
There’s another method of adding custom hostnames by not tampering with /etc/hosts, but I’ll leave it for another blog post.