Home > rails > Rails Note #4: Deploying a Rails Application in a Subdirectory

Rails Note #4: Deploying a Rails Application in a Subdirectory

November 7th, 2008 rupert

There are many ways to deploy RoR applications. I have googled all over the place and so far the easiest setup that I could find that would suit my needs (existing Apache2 + ColdFusion + TileCache) would be to use

1. Apache PROXY
2. Mongrel

CentOS Installation Instructions

1. Make sure Apache has mod_proxy

 ./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite --with-mpm=prefork --enable-proxy --enable-proxy-connect --enable-proxy-ftp --enable-proxy-httpd --enable-proxy-ajp --enable-proxy-balancer --enable-cgi

1. Apache Proxy

<VirtualHost *:80>
    ServerName test
    ProxyRequests Off 
        <Proxy *>
            Order deny,allow
            Allow from all
        </Proxy>
    ProxyPass /localdumplings http://localhost:3000/localdumplings
    ProxyPassReverse /localdumplings http://localhost:3000/localdumplings
    #ProxyPass /localdumplings/ http://localhost:3000/
    #ProxyPassReverse /localdumplings/ http://localhost:3000/
</VirtualHost>

2. Starting mongrel on a subdir
mongrel_rails start –prefix=/localdumplings

Debian Installation Instructions

1. Install libapache2-mod-proxy-html is easier…

sudo apt-get install libapache2-mod-proxy-html

2. Enable modules to load in apache2

sudo a2enmod proxy
sudo a2enmod proxy_balancer
sudo a2enmod proxy_http
sudo a2enmod rewrite
sudo /etc/init.d/apache2 stop
sudo /etc/init.d/apache2 start

3. Add the application in /etc/apache2/mods-available/proxy.conf

<IfModule mod_proxy.c>
        #turning ProxyRequests on and allowing proxying from all may allow
        #spammers to use your proxy to send email.
 
        ProxyRequests Off 
 
        <Proxy *>
                AddDefaultCharset off 
                Order deny,allow
                Allow from all
                #Allow from .example.com
        </Proxy>
 
        # Enable/disable the handling of HTTP/1.1 "Via:" headers.
        # ("Full" adds the server version; "Block" removes all outgoing Via: headers)
        # Set to one of: Off | On | Full | Block
        ProxyPass /localdumplings http://localhost:3000/localdumplings
        ProxyPassReverse /localdumplings http://localhost:3000/localdumplings
 
        ProxyVia On
</IfModule>

Starting a mongrel_rails on boot
Slicehost ( http://articles.slicehost.com/2007/9/21/debian-etch-apache-vhosts-rails-and-mongrels ) has a very good article regarding this.

mongrel_rails start -d -e production -p 8001 -P log/mongrel8001.pid -l log/mongrel.log
Categories: rails Tags: , ,
Comments are closed.