Getting 2 rails apps running on a server?

hi, i’m using SliceHost as my hoster and running Ubuntu 6.10 on it, but
got a problem when i’m trying to get more than one rails app running on
my box.

basically i’ve used capistrano + deprec to deploy the first one, works
fine and no problems there, deployed the second one and that looks ok
via capistrano,

however got confused with the settings in my apache httpd.conf file and
the two app.conf files, hope you can help?

first off i followed the guide,

http://wiki.slicehost.com/doku.php?id=multiple_rails_apps_on_one_slice

to get the second rails app on the box, used…

cap deprec_setup
cap deploy_with_migrations

that went fine and managed to get subversion working for the source
repositories, good.

now onto the setting files,

in the first apps, deploy.rb

set :apache_proxy_port, 8000

second app has,

set :apache_proxy_port, 9000

so both are using different port addresses,

now onto the mongrel cluster settings,

/etc/mongrel_cluster/firstapp.yml

cwd: /var/www/apps/first/current
port: “8000”
environment: production
address: 127.0.0.1
pid_file: log/mongrel.pid
servers: 2

/etc/mongrel_cluster/secondapp.yml

cwd: /var/www/apps/second/current
port: “9000”
environment: production
address: 127.0.0.1
pid_file: log/mongrel.pid
servers: 2

now in the apache app configs,

/usr/local/apache2/conf/apps/firstapp.conf

<VirtualHost *:80>
ServerName firstapp.com
ServerAlias www.firstapp.com
DocumentRoot /var/www/apps/first/current/public
<Directory /var/www/apps/first/current/public>
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all

Configure mongrel_cluster

<Proxy balancer://first_cluster>
BalancerMember http://127.0.0.1:8000
BalancerMember http://127.0.0.1:8001

and…

/usr/local/apache2/conf/apps/secondapp.conf

<VirtualHost *:8080>
ServerName secondapp.com
ServerAlias www.secondapp.com
DocumentRoot /var/www/apps/second/current/public
<Directory /var/www/apps/second/current/public>
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all

Configure mongrel_cluster

<Proxy balancer://second_cluster>
BalancerMember http://127.0.0.1:9000
BalancerMember http://127.0.0.1:9001

…in my /usr/local/apache2/conf/httpd.conf

i’ve stated the servername [ip address]

ServerName 208.75.85.16

…but not the port :8080 and :80 at the end, should I ?

plus these extra bits at the end,

Listen 80
Listen 8080
Include conf/apps/
NameVirtualHost *:80
NameVirtualHost *:8080

the dns has an A record relating the first.com > 208.75.85.16
and the second to second.com > 208.75.85.16

however after rebooting both the mongrel clusters with

/first/cap restart_mongrel_cluster
/second/cap restart_mongrel_cluster
/second/cap restart_apache

…the domain name for the second app is still pointing to the first
app,

e.g.

www.first.com > firstapp
www.second.com > firstapp

any ideas what i’ve missed in my settings?

really totally dumbfounded & desperate for help,

(will buy beer for answers?)

Hey John

I have a similar setup SliceHost, ubuntu, and what not.

And I remember having the same problem when trying to host two
applications.

Looking over your set up and comparing it to mine. Your vhost conf
files are different than mine.

My httpd-vhost.conf file is located in usr/local/apache2/conf/extra
and is as follows.

NameVirtualHost *:80

<VirtualHost *:80>
ServerName www.mydomain.com
ServerAlias mydomain.com
DocumentRoot /var/www/apps/myapp1/current/public

<Directory /var/www/apps/myapp1/current/public>
  Options FollowSymLinks
  AllowOverride All
  Order allow,deny
  Allow from all
</Directory>

# Configure mongrel_cluster
<Proxy balancer://scoop_cluster>
  BalancerMember http://127.0.0.1:9000
  BalancerMember http://127.0.0.1:9001
</Proxy>

RewriteEngine On

# Prevent access to .svn directories
RewriteRule ^(.*/)?\.svn/ - [F,L]
ErrorDocument 403 "Access Forbidden"

# Check for maintenance file and redirect all requests
RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ /system/maintenance.html [L]

# Rewrite index to check for static
RewriteRule ^/$ /index.html [QSA]

# Rewrite to check for Rails cached page
RewriteRule ^([^.]+)$ $1.html [QSA]

# Redirect all non-static requests to cluster
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ balancer://scoop_cluster%{REQUEST_URI}

[P,QSA,L]

# Deflate
AddOutputFilterByType DEFLATE text/html text/plain text/xml
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
ErrorLog logs/ip.address-error_log
CustomLog logs/ip.address-access_log combined

<VirtualHost *:80>
ServerName www.mydomain2.com
ServerAlias mydomain2.com
DocumentRoot /var/www/apps/secondapp/current/public

<Directory /var/www/apps/secondapp/current/public>
  Options FollowSymLinks
  AllowOverride All
  Order allow,deny
  Allow from all
</Directory>

# Configure mongrel_cluster
<Proxy balancer://firstapp_cluster>
  BalancerMember http://127.0.0.1:8000
  BalancerMember http://127.0.0.1:8001
</Proxy>

RewriteEngine On

# Prevent access to .svn directories
RewriteRule ^(.*/)?\.svn/ - [F,L]
ErrorDocument 403 "Access Forbidden"

# Check for maintenance file and redirect all requests
RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ /system/maintenance.html [L]

# Rewrite index to check for static
RewriteRule ^/$ /index.html [QSA]

# Rewrite to check for Rails cached page
RewriteRule ^([^.]+)$ $1.html [QSA]

# Redirect all non-static requests to cluster
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ balancer://firstapp_cluster%{REQUEST_URI}

[P,QSA,L]

# Deflate
AddOutputFilterByType DEFLATE text/html text/plain text/xml
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
ErrorLog logs/ipaddress-error_log
CustomLog logs/ipaddress-access_log combined

I don’t know if that helps. I am pretty rough at the whole deployment
process. But I do know that this setup is working for me at the
moment on Slicehost. So it might be worth a try.

kirk out

On Aug 17, 4:20 am, John G. [email protected]

Change the virtual host for the second app to listen on port 80 instead
of
8080, or put :8080 at the end the URL and you should be good to go. All
your virtual servers can listen on 80 as long as your Mongrels are
running
on separate higher numbered ports.
Shane

On 8/17/07, John G. [email protected] wrote:

however got confused with the settings in my apache httpd.conf file and

port: “8000”
environment: production
ServerName firstapp.com
BalancerMember http://127.0.0.1:8000
DocumentRoot /var/www/apps/second/current/public

plus these extra bits at the end,


http://shanesbrain.net
http://five.sentenc.es/

Excellent work, you two!

Going to try this out, was always told to put in an extra port to listen
in apache, didn’t know the two apps could use the same but just divide
their mongrel addresses.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs