[Ruby] rails question
Alex Vollmer
alex.vollmer at gmail.com
Tue Aug 21 07:27:21 PDT 2007
> so, i have a website hosted on a server with multiple vhosts. we use
> Apache web server. i want to create a calendar application and deploy
> it to my server. I am not entirely sure how to do that. I have rails
> apps using various single install solutions but that doesn't really work
> here. So I guess my question is, how do you deploy a rails app to a
> multiple vhost server?
>
>
Raymond, if you're using Mongrel, check out
http://mongrel.rubyforge.org/docs/apache.html for details on hooking Mongrel
into apache. Essentially you have two main stanzas of apache configuration:
one for configuring the ProxyPass module and a virtual host for your mongrel
application. Here's a commented example:
### Load all the modules that are needed
LoadModule headers_module /usr/local/apache2/modules/mod_headers.so
LoadModule proxy_module /usr/local/apache2/modules/mod_proxy.so
LoadModule proxy_balancer_module
/usr/local/apache2/modules/mod_proxy_balancer.so
LoadModule proxy_http_module /usr/local/apache2/modules/mod_proxy_http.so
LoadModule rewrite_module /usr/local/apache2/modules/mod_rewrite.so
### Specific configuration for the proxy module
<IfModule mod_proxy.c>
ProxyRequests Off
<Proxy *>
Order deny,allow
Deny from all
#Allow from .your_domain.com
</Proxy>
ProxyVia On
</IfModule>
### Declare a balancer configuration (referenced later)
<Proxy balancer://mongrel_cluster>
BalancerMember http://127.0.0.1:8800
BalancerMember http://127.0.0.1:8801
BalancerMember http://127.0.0.1:8802
BalancerMember http://127.0.0.1:8803
BalancerMember http://127.0.0.1:8804
BalancerMember http://127.0.0.1:8805
</Proxy>
### This is where you hook mongrel into apache
<VirtualHost *:80 *:443>
ServerName www.example.com
DocumentRoot /apps/myapp/current/public ### This allows apache to serve
static files
<Location "/">
Order Allow,Deny
Allow from all
</Location>
</VirtualHost>
### This allows apache to work with all of the symlinks Capistrano creates
<Directory "/apps/myapp">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
### Specific configuration for the 'public' directory
<Directory "/apps/myapp/current/public">
Options FollowSymLinks
AllowOverride None
Order Allow,Deny
Allow from all
### The rewrite module is used to figure out what requests apache handles
### and which requests are passed to the mongrel cluster (via ProxyPass)
RewriteEngine On
# Check for maintenance file and redirect all requests
RewriteCond /apps/portal/current/public/system/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ /system/maintenance.html [L]
# Redirect all non-static requests to cluster
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ balancer://mongrel_cluster/$1 [P,QSA,L]
</Directory>
Hopefully that helps.
Cheers,
Alex V.
--
Musings and notes -- http://blog.livollmers.net
More information about the Ruby
mailing list