Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I am trying to host multiple versions (dev and staging) of a Rails app on the same server, but I am not currently able to access both via the browser.

I am running with Apache2, Passenger, Rails 3, and Ubuntu 10.04 LTS.

I would like to access the 2 sites via the same IP but with different ports. Is this allowed? When I access the staging environment via "", it works just fine, but when I try to access the dev environment via "", the browser says it cannot connect to "".

In theory, should this work? Do I need to assign actual domains (e.g. "http://example.com" and "http://dev.example.com")?

# ports.conf

Listen 80
NameVirtualHost *:80
Listen 8080
NameVirtualHost *:8080

# sites-enabled/staging-example.com

<VirtualHost *:80>
  ServerName example.com
  DocumentRoot "/home/www/example/staging/current/public"
  <Directory "/home/www/example/staging/current/public">
    Allow from all
    Options -MultiViews   

# sites-enabled/dev-example.com

<VirtualHost *:8080>
  ServerName dev-example.com
  DocumentRoot "/home/www/example/dev/current/public"
  <Directory "/home/www/example/dev/current/public">
    Allow from all      
    Options -MultiViews   
    RailsEnv development

Note: I also created the config/setup_load_paths.rb as recommended by http://dalibornasevic.com/posts/21-rvm-and-passenger-setup-for-rails-2-and-rails-3-apps.

share|improve this question
The config looks ok, have you checked your firewall isn't blocking port 8080? But using multiple domains might be easier than having to worry about what ports go where etc. If you have a public server enter the hostname and port at ping.eu/port-chk and it'll tell you if your Firewall is blocking it –  sam Jun 4 '11 at 14:38
Using ping.eu/port-chk, it looks like port 80 is open, but 8080 is closed. So, that might be problem. I have not yet set up a firewall, but I may need to do something to explicitly open port 8080 for apache. I'll look into this! –  bporter Jun 4 '11 at 14:44

1 Answer 1

Passenger is probably configured to publish both apps on port 80 (I don't see a custom config to override this anywhere).

Still, I would use vhosts with domains, ie:

NameVirtualHost <IP>:80

<VirtualHost <IP>:80>
    ServerName www.x.com
    ServerAlias x.com
    <DocumentRoot  //etc, left out for simplicity...

<VirtualHost <IP>:80>
    ServerName www.dev-x.com
    ServerAlias dev-x.com
    <DocumentRoot //etc, left out for simplicity...

Filling out the rest should let apache point you at the right server.

Hope that helps, let me know if that's not clear


By the way, since you're on Ubuntu, you can just add each of those vhost configs to sites-available and use the a2ensite to turn them on/off => we've got 2 servers we're using like this, and the first has about 15 different sites on it, the second has about 10.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.