1

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>
    #ServerAdmin @dummy-host.example.com
    DocumentRoot /webserver/myapp/public
    ServerName myapp-Development
    <Directory /webserver/myapp/public>
         AllowOverride all
         Options -MultiViews
    </Directory>
    ErrorLog logs/k2-error_log
    CustomLog logs/k2-access_log common
</VirtualHost>

<VirtualHost *:3000>
    #ServerAdmin @dummy-host.example.com
    DocumentRoot /webserver/myapp2-admin/public
    ServerName myapp2-admin
    <Directory /webserver/myapp2-admin/public>
         AllowOverride all
         Options -MultiViews
    </Directory>
    #ErrorLog logs/k2-error_log
    #CustomLog logs/k2-access_log common
</VirtualHost>

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?

OR

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: https://stackoverflow.com/questions/4203580/creating-subdomains-in-amazon-ec2

1

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

  • 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
1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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