Running a RoR application in Solaris 10 with Apache 2 and FastCGI using pkgsrc

Just a little reminder about how to enable fastcgi applications (for RoR application for example) in Solaris 10 with packages provide by pkgsrc.

Packages requirements

# cd /usr/pkg/www/ap2-fastcgi
# sudo bmake install

# cd /usr/pkgsrc/www/ruby-fcgi
# sudo bmake install

# cd /usr/pkgsrc/misc/rubygems
# sudo bmake install

# sudo gem install -y rails

# sudo mkdir -p /var/run/fastcgi
# sudo chown webservd:webservd /var/run/fastcgi

Apache 2

apache2.conf

LoadModule fastcgi_module     /usr/pkg/lib/httpd/mod_fastcgi.so

<IfModule mod_fastcgi.c>
  AddHandler fastcgi-script .fcgi
</IfModule>

virtual-host.conf

<IfModule mod_fastcgi.c>
   FastCgiServer  /var/www/demo.asyd.net/roradius/public/dispatch.fcgi -processes 3 -initial-env RAILS_ENV=development -idle-timeout 120
</IfModule>

<Directory /var/www/demo.asyd.net/roradius/public/>
   AllowOverride all
</Directory>

<VirtualHost *:80>
   ServerName demo.asyd.net

   DocumentRoot   /var/www/demo.asyd.net/roradius/public/

   Alias /roradius/  /var/www/demo.asyd.net/roradius/public/
   DocumentRoot /var/www/demo.asyd.net/htdocs

</VirtualHost>

SQLite 3

If you want use SQLite3,

# cd /usr/pkgsrc/database/sqlite3
# sudo bmake install
# cd /usr/pkgsrc/database/ruby-sqlite3
# sudo bmake install

RAILS_ROOT/public/.htaccess

Be sure to uncomments RewriteRules and set dispatch.fcgi