Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Ok, so my set up is as follows:

  • I own a domain, let's call it domain.com.
  • I have an amazon AWS account with one micro-instance (free tier).
  • domain.com and www.domain.com both point to a static IP set up for my instance.
  • Instance is Amazon Linux with apache2 web server. Doc root is the default: /var/www/html
  • I have also set up apps.domain.com that points to www.domain.com/apps as a frame URL (This is what needs changing!).

What I want is to have two doc roots (if that's possible), one for my main forward facing site (www.domain.com), let's say I keep it as it is in /var/www/html. But then I need another one for playing around and building apps etc. I would like to serve them up from /var/www/apps and I would point to that from apps.domain.com.

The reason for this is that I need to be able to have versioning control over the web apps I build, I would keep a separate tree for each one within /var/www/apps. At the moment my apps are served up from /var/www/html/apps so they are under the version control of my main site in html; not ideal.

Ok, I think I've got over as much as I need, hopefully it is understood what I would like achieved. So is this all possible? I can set up multiple static IPs with AWS so maybe each of them can resolve to different doc roots? I'm just getting into the infrastructure side of things so don't know too much about it all, bear with me!

share|improve this question
3  
It tickles me to see this question. This is how hosting multiple websites on a single server was originally done, until the Host: header was added to HTTP, allowing many sites on one IP. –  James O'Gorman Dec 30 '11 at 18:40
1  
@JamesO'Gorman Haha, oh it's that obvious I'm a newbie is it! Oh well everybody's got to learn sometime ;) –  igneosaur Dec 30 '11 at 20:51

2 Answers 2

up vote 6 down vote accepted

Yes.

See the Apache Documentation, and specifically the Virtual Host examples, one of which is partially reproduced below (vhosts distinguished by IP address).

# First Virtual Host (e.g. your main website)    
<VirtualHost 172.20.30.40>
DocumentRoot /www/example1
ServerName www.example.com
</VirtualHost>

# Second Virtual Host (e.g. your apps)
<VirtualHost 172.20.30.50>
DocumentRoot /www/example2
ServerName www.example.org
</VirtualHost>
share|improve this answer
    
NameVirtualHosts will be better, because they can run on the same ip address. –  becomingwisest Dec 30 '11 at 18:39
1  
@ChristopherEvans NameVirtualHosts are another possibility, but they are not a universal solution (particularly if you need SSL support in older browsers) -- The choice is really up to igneosaur though, they need to read the docs, understand the capabilities and limitations of each option, and select the appropriate solution for their situation. –  voretaq7 Dec 30 '11 at 18:45
    
Ok, I've learned a fair bit today and managed to get everything working, thanks everyone for their help! –  igneosaur Dec 31 '11 at 0:45

You should read about Apache virtual hosts.

share|improve this answer

Your Answer

 
discard

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.