Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I previously ran an two Ruby and Rails applications, one of them by using rails console command, the another one using Apache trough Phusion Passenger. Both applications ran in same IP, the only difference was the application running wih rails console was accesible from port 3000.

Now, I would like to run both apps with Apache, but I know what exactly configure to do that. I read something VirtualHosts, but i don't get it. Considering that I only have one server and one domain, i just used a different port. I tried several times to something similar to this:

<VirtualHost *:80>
    DocumentRoot /webserver/myapp/public
    ServerName myapp-Development
    <Directory /webserver/myapp/public>
         AllowOverride all
         Options -MultiViews
    ErrorLog logs/k2-error_log
    CustomLog logs/k2-access_log common

<VirtualHost *:3000>
    DocumentRoot /webserver/myapp2-admin/public
    ServerName myapp2-admin
    <Directory /webserver/myapp2-admin/public>
         AllowOverride all
         Options -MultiViews
    #ErrorLog logs/k2-error_log
    #CustomLog logs/k2-access_log common

Didn't work, i just have access to the first application by typing the IP in browser.

How can I have 2 RoR applications in same server available in different ports?


OPTIONAL: How can I have myapp2 to run in same port 80, but available in this direction: some.ip.address/admin?

Using CentOS 5.7 in a Amazon EC2 instance.

I found an answer in this question, the problem is that I dont' have a domain to create CNAMES records for subdomains:

share|improve this question

You probably forgot to edit, ports.conf, you need to add another Listen to make apache bind to that port as well.

share|improve this answer
And where is this file? – Mr_LinDowsMac Mar 16 '12 at 23:27
On centos apparently the directive resides in /etc/httpd/conf/httpd.conf – Lucas Kauffman Mar 17 '12 at 10:50

check my answer here to a similar question about serving multiple rails applications from sub-url's.

If you want to server your two rails apps from two different ports, apart from the virtual host, you have to also add to your apache conf

Listen 80
Listen 3000
NameVirtualHost *:80
NameVirtualHost *:3000
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.