Rails Machine Wiki

Apache Server Alias

If you need your application to respond to several different domain name there are two ways to accomplish this.

In either case, you first need to add a DNS record so that the new domain or subdomain points to your server’s IP address.

Using Capistrano

If you’re not using SSL, you can let Capistrano make the change for you.

On your development computer, edit your app’s deploy.rb and change this line:

# set :apache_server_aliases, %w{alias1 alias2}

to this:

set :apache_server_aliases, %w{ yournewdomain.com www.younewdomain.com}

Add as many aliases as you need. Then re-write your apache configuration by running this:

cap web:setup web:restart

Editing Apache Configuration

If you are using SSL, the safest method is to edit the Apache configuration manually on the server:

vi /etc/httpd/conf/apps/yourapp.conf

Look for the two lines in the file that start with Server Alias. Add your new domain(s) like this:

ServerAlias yournewdomain.com www.yournewdomain.com

Save the file, then restart Apache

sudo /sbin/service httpd restart'