# Getting 2 rails apps running on a server?

**URL:** <https://www.ruby-forum.com/t/getting-2-rails-apps-running-on-a-server/112315>\
**Category:** Deployment\
**Created:** [August 17, 2007, 11:20am UTC](https://www.ruby-forum.com/t/getting-2-rails-apps-running-on-a-server/112315 "2007-08-17T11:20:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![softf5ajivanet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9f8e36/32.png) [@softf5ajivanet](https://www.ruby-forum.com/u/softf5ajivanet)\
**Post date:** [August 17, 2007, 11:20am UTC](https://www.ruby-forum.com/t/getting-2-rails-apps-running-on-a-server/112315/1 "2007-08-17T11:20:48Z")

</div>

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](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](http://firstapp.com)  
ServerAlias [www.firstapp.com](http://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](http://127.0.0.1:8000)  
BalancerMember [http://127.0.0.1:8001](http://127.0.0.1:8001)

and…

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

\<VirtualHost \*:8080\>  
ServerName [secondapp.com](http://secondapp.com)  
ServerAlias [www.secondapp.com](http://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](http://127.0.0.1:9000)  
BalancerMember [http://127.0.0.1:9001](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](http://first.com) \> 208.75.85.16  
and the second to [second.com](http://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](http://www.first.com) \> firstapp  
[www.second.com](http://www.second.com) \> firstapp

any ideas what i’ve missed in my settings?

really totally dumbfounded & desperate for help,

(will buy beer for answers?)

---

<div class="post-metadata">

**Author:** ![softf5ajivanet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9f8e36/32.png) [@softf5ajivanet](https://www.ruby-forum.com/u/softf5ajivanet)\
**Post date:** [August 19, 2007, 3:16am UTC](https://www.ruby-forum.com/t/getting-2-rails-apps-running-on-a-server/112315/2 "2007-08-19T03:16:21Z")

</div>

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](http://www.mydomain.com)  
ServerAlias [mydomain.com](http://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](http://www.mydomain2.com)  
ServerAlias [mydomain2.com](http://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. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![softf5ajivanet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9f8e36/32.png) [@softf5ajivanet](https://www.ruby-forum.com/u/softf5ajivanet)\
**Post date:** [August 19, 2007, 9:03am UTC](https://www.ruby-forum.com/t/getting-2-rails-apps-running-on-a-server/112315/3 "2007-08-19T09:03:45Z")

</div>

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. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> however got confused with the settings in my apache httpd.conf file and
> 
> port: “8000”  
> environment: production  
> ServerName [firstapp.com](http://firstapp.com)  
> BalancerMember [http://127.0.0.1:8000](http://127.0.0.1:8000)  
> DocumentRoot /var/www/apps/second/current/public  
>   
> plus these extra bits at the end,
> 
> >

–  
[http://shanesbrain.net](http://shanesbrain.net)  
[http://five.sentenc.es/](http://five.sentenc.es/)

---

<div class="post-metadata">

**Author:** ![softf5ajivanet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9f8e36/32.png) [@softf5ajivanet](https://www.ruby-forum.com/u/softf5ajivanet)\
**Post date:** [August 19, 2007, 11:03am UTC](https://www.ruby-forum.com/t/getting-2-rails-apps-running-on-a-server/112315/4 "2007-08-19T11:03:59Z")

</div>

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.
