How to Serve Multiple Domains

Most people serve more than one domain on their Cloud Server(s).

Whether for different domain names or different subdomains of the same domain, the procedure is the same.




When your Cloud Server is first created it is a minimal Linux install (it doesn't matter what OS you choose).

You SSH into the Cloud Server and update and secure it.

Then you install your preferred web server (Apache, Nginx, Litespeed, etc).

Then the detailed stuff begins. It doesn't matter if your site is PHP based or Rails based or something else entirely. You install the language and framework basics (say Ruby and rubygems or mod_php and so on).

Once that is all done, you come to the part that allows you to server your site: creating virtual hosts.


Greatly simplified the procedure for serving a website is as follows:

A browser sends a request to your Cloud Server IP asking for the contents of '' (your domain name).

Your web server jumps into action and says 'yes! I have something for you'. The web server does its 'thing' and serves up an http representation of your site which is sent to the browser.

The browser then translates the http and parses it to a human form of the web site (something like this one).

All jolly good but how does your web server know what to send?

Virtual Hosts

This is where name based virtual hosts come in.

One of the first lines in any virtual host contains the domain name that is related to the vhost.

Something like this for Apache:

<VirtualHost *:80>



and something like this for Nginx:

server {

  rewrite ^/(.*)$1 permanent;

Each one starts slightly differently but the same principle applies - that particular virtual host will respond to queries for '' and ''.

Multiple domains

So, to serve different content for different domains is as simple as adding another virtual host.

Let's say you have a subdomain called '' serving a blog (I know, shocking originality!).

The basic creation process would be to create a folder in your public_html folder with the relevant files (let's say a Wordpress install).

A virtual host would be created with the server_name or ServerName as '' which would be configured to point to the blog files and folders in your public_html folder.

Language and frameworks

It doesn't matter what language or framework your domain uses.

To serve multiple Rails applications for example requires the same setup for each application.

Of course, there would be some differences such as port numbers for the mongrel or thin instances. Virtual hosts can't share ports.

For example, you may create a mongrel cluster to run from port 8000 - 8002 for one domain and another running from 8010 - 8012 for your blog and so on.


Once the Cloud Server has been setup and the web server has been installed, serving multiple domains is very easy:

Simply create more vhosts.

Was this content helpful?

© 2015 Rackspace US, Inc.

Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License

See license specifics and DISCLAIMER