Phusion Passenger ( mod_rails ) is out so I thought I would give it a twirl. The mod_rails site has some install notes but it doesn’t go far enough. However, once you do the install and get used to it, it is a rather friendly setup. I can see it being a big boost to rails shared-hosting. The rails instances are scaled up and down on the fly behind apache so no static pre-configured pools of mongrel with monit watching them needed. Here’s how I got it going on the mac:
Update 6/16: Moved instructions to MacPorts instead of raw install
# Install macports + macports ruby + macports rubygems
sudo port install apache2 +preforkmpm
export APACHE=/opt/local/apache2
export PATH=$APACHE/bin:$PATH
sudo gem install rails passenger
export VERS=`passenger-config --version`
sudo passenger-install-apache2-module
sudo cp $APACHE/conf/httpd.conf.sample $APACHE/conf/httpd.conf
sudo chgrp -R admin $APACHE/conf
sudo chmod -R g+w $APACHE/conf
sudo chmod 2775 $APACHE/conf $APACHE/conf/extra
echo "Include conf/extra/httpd-rails.conf" >> $APACHE/conf/httpd.conf
cat >$APACHE/conf/extra/httpd-rails.conf <<EOF
LoadModule passenger_module /opt/local/lib/ruby/gems/1.8/gems/passenger-$VERS/ext/apache2/mod_passenger.so
RailsSpawnServer /opt/local/lib/ruby/gems/1.8/gems/passenger-$VERS/bin/passenger-spawn-server
RailsRuby /opt/local/bin/ruby
NameVirtualHost *
<VirtualHost *>
ServerName myapp.com
ServerAlias *.myapp.com
RailsEnv development
# For each webapp
DocumentRoot /Users/me/Projects/myapp/public
<Directory /Users/me/Projects/myapp/public>
Allow from all
</Directory>
</VirtualHost>
EOF
sudo $APACHE/apachectl start
exit
That’s it. You can see that you can add more <VirtualHost *> entries for other applications. You need to put www.myapp.com hostname on the end of the “localhost” line in /etc/hosts.
Posted on April 14th, 2008 by dysinger
Filed under: @work
hi there,
I’ve done exactly as you told on your blog, but still I got the following :
Welcome to the Passenger Apache 2 module installer, v1.0.5.
This installer will guide you through the entire installation process. It
shouldn’t take more than 3 minutes in total.
Here’s what you can expect from the installation process:
1. The Apache 2 module will be installed for you.
2. You’ll learn how to configure Apache.
3. You’ll learn how to deploy a Ruby on Rails application.
Don’t worry if anything goes wrong. This installer will advise you on how to
solve any problems.
Press Enter to continue, or Ctrl-C to abort.
Checking for required software…
* GNU C++ compiler… found at /usr/bin/g++
* Ruby development headers… found
* OpenSSL support for Ruby… found
* RubyGems… found
* Rake… found at /usr/local/bin/rake
* Apache 2… not found
* Apache 2 development headers… found at /usr/local/apache2
* Apache Portable Runtime (APR) development headers… found at /usr/local/bin/apr-1-config
* fastthread… found
Some required software is not installed.
But don’t worry, this installer will tell you how to install them.
Press Enter to continue, or Ctrl-C to abort.
——————————————–
Installation instructions for required software
* To install Apache 2:
Please download it from http://httpd.apache.org/
Previously this is my work around on apache2, instead of having them compile on my /tmp, I preferred them to go on my /usr/local/src. But after several attempt, it failed. So I gave up and had them in tmp instead.
Afterward, configure them like this one instead ./configure –prefix=/usr/local/src, but it still failed, don’t know what when wrong? So decided went off with the default ./configure instead. But something when wrong, and I stated in the above snippets, I still got the
* Apache 2… not found
Any idea what when wrong?
Ooooouch… I also forgot to mention, I’m on Tiger…
“export APXS2=/usr/local/apache2″
This is actually not correct. APXS2 must point to the apxs2 binary, e.g.:
export APXS2=/usr/local/apache2/bin/apxs
-OR-
export APXS2=/usr/local/apache2/bin/apxs2
…depending on the exact filename of your apxs2 binary.
could you post your /etc/hosts file? I’ve got everything working up to there. Thanks a lot for the post.
For development on your laptop, you basically just need a /etc/hosts that has something like this:
replace “sub” and “sub1″ with your test subdomains (if you even need subdomains). Add as many as you like. unfortunately you cannot have wildcards in /etc/hosts so you have to list all your test subdomains.