Multiple Hosts Layout

During these articles I will be talking about different operating systems, different web servers and different, er, stuff.

To make things easier to understand and reference between articles and systems, I will use a 'standard' layout for hosting multiple sites (virtual hosts). Let me explain the layout I use.



As you know, there are several differences between distributions and not just in libraries, package management and so on.

The default directory locations for serving domains also differs. Some default to /var/www/ and some to /srv/www/. Some organisations recommend /srv/


The way I will use is not the only way, nor is it special or the Cloud Servers way.

It is, however, one way of organizing your domains in one place and will work across different operating systems and web servers.

I will also mention that if you are using a shared hosting environment on your Cloud Server then do stick with the OS defaults. My method places the domain directories in my home directory.

I am the only user of my Cloud Server and this is, as far as I am aware, the case with the vast majority of Cloud Server users, so I do not have to be concerned about other users logging in and accessing my home directory (apart from the usual security measures that is).


My domains are laid in their own directories in my /home/demo/public_html folder (demo is my main user name).

In each domain, I have a standard set of folders including logs, cgi, private, public, backup and so on but feel free to add/delete directories as you see fit.

One advantage of this layout is consistency between technologies. A standard Ruby on Rails application will have many directories with the main content being served from the 'public' directory.

My layout coincides with this so my plain html and dynamic PHP content are also served from the directory.

I can't incorporate every technology into one layout but I think this covers most eventualities. Specific articles (such as using Capistrano) will note the differences.


Let's take a look at the folders in use throughout these articles:


So in this example I have three domains - each in their own directory. I always class subdomains as separate from the 'main' domain. After all, they have different content.


Let's look in detail at the folder:


The layout is quite simple once you get used to all the connections:

public: where publicly served files, images, etc are placed.

private: used for files you do not want in the public domain such as PHP mysql connection files.

cgi-bin: umm, the cgi-bin

logs: place domain logs here - it keeps them separate and easily accessible.

backup: I place daily database backups here - makes for easier cloud server backups.


Naturally, add/delete folders as you see fit. However, this is the layout that will be used throughout the articles when it comes to domain configurations.

Also, do use the OS default if you feel more comfortable doing so. Simply adjust the paths used in the demonstrations.

© 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