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 recently decided to try out Rails. When working with PHP, I simply had all of my PHP projects in the same directory. For example, I may have http://ubuntu/app1, http://ubuntu/app2, etc.

I created a subdomain for Rails (http://ruby.ubuntu), installed Rails and Passenger and everything is working. However, I may be wrong, but it looks like I can only have one Rails app per subdomain?

My VirtualHost is as follows:

<VirtualHost *:80>
    ServerName ruby.ubuntu
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www/ruby/blog/public

    <Directory /var/www/ruby/blog/public>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
        RailsEnv development

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined


All of my PHP and misc. files are stored in /var/www/main. I want to be able to store all of my Rails apps in /var/www/ruby. I tried changing DocumentRoot to /var/www/ruby, but I don't think it's as simple as that. When I browse to a Rails app's Welcome Aboard page and click on "About my application's environment," I get a 404 page, but when the DocumentRoot is set to the public directory, I get the expected result.

I don't want to have to create a new subdomain every time I create a new project. Is there any way I can make it so I can store all of my apps in /var/www/ruby, and browsing to http://ruby.ubuntu will let me access all of my Rails apps there? That way if I want to create a new app, all I have to do is rails new app, no Apache .htaccess or VirtualHost configuration required.

share|improve this question
possible duplicate of Multiple Rails sites using Passenger and VirtualHosts? – womble Jul 7 '12 at 17:02

you can serve as many rails applications as you wish.

If using apache httpd and passenger, here are the steps:

Just symlink public folder of each of your rails application into apache's DocumentRoot as a subfolder. Then add a RailsBaseURI directive in your apache config that tells passenger that the given folder is a rails application.

Lets say you have two rails apps rapp1 and rapp2. Lets say your apache DocumentRoot is /var/www/html

  ln -s rapp1 /var/www/html/rapp1
  ln -s rapp2 /var/www/html/rapp2

now open your apache virtual host configuration file and add the following two lines

  RailsBaseURI /rapp1
  RailsBaseURI /rapp2

restart your apache server and when you visit http://servername/rapp1, your rails application gets served

share|improve this answer

I could be mistaken but I believe what you're trying to achieve is called Sub-URI's.

Use the ruby.ubuntu subdomain and then each application runs under different /subdirectories.

Some further reading:

share|improve this answer
Forgive me if I'm wrong, but doesn't Sub-URI only assign a URI to a folder in the same way that Apache's mod_alias does? Using Sub-URI, I would have to create a new rule for every application. – Derek Maciel Jul 7 '12 at 22:36

It looks like you're trying to use SubURIs. Passenger can support them, but you need to tweak your Virtual Host configuration a little.

The Passenger Docs for Apache explain how to do it, along with an example to give you a hand.

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.