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.
Differences
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/domain.com/.
Consistency
The way I will use is not the only way, nor is it special or the 'Slicehost' way.
It is, however, one way of organising 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 Slice then do stick with the OS defaults. My method places the domain directories in my home directory.
I am the only user of my Slice and this is, as far as I am aware, the case with the vast majority of Slice 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).
Layout
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 domain.com/public 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.
Folders
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.
Details
Let's look in detail at the domain1.com 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 slice backups.
Change
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.
PickledOnion.

Subscribe to Feed
Article Comments:
Andy commented 3 months ago:
Hello. After reviewing this article and the DNS article, I still have a question. You put
admin.domain1.comin it's own folder as a peer of the other top-level domain folders, since it has different content.I don't completely understand what the
Arecordadminwould look like in the SliceManager. What would you put in the data field?I'd like to (like others I'm sure) have subdomains: wiki, blog, articles etc.
Another way to answer this question might be to share how Slicehost itself is configured. Thanks! Great articles , concise and clear writing.
PickledOnion commented 3 months ago:
Hi Andy,
Not sure how Slicehost is configured has anything to do with this.
When you create a subdomain you enter the name of the subdomain (such as 'www' or 'blog') and the IP address of your Slice.
That's it for the subdomain DNS record.
You would then configure a vhost in whichever webserver you used to point to the folder structure for that domain.
Hope that helps.
PickledOnion
Andy commented 3 months ago:
I haven't set up a vhost before, but I was reading the Gutsy Apache configuration and it seems manageable. I don't think Slicehost uses any other TLDs so yeah, Slicehost config doesn't have much relevance for this article. Thanks for the quick response! BTW- I think it is great Slicehost doesn't put these articles behind a password-protected portion of the site.
Marvin commented 3 months ago:
How does this file structure apply to rails apps ? When I start a new rails app with : rails railsapp, where in this file structure should I put the rails files ?
seth commented about 1 month ago:
marvin: you'd want to do one of 2 things, either rails projectname inside of the public folder that PO specified, OR you could simply do away with the public folder and just put create your rails app in the root of your domain folder.