Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to host two different sites on the same IP, same server, and same domain using Apache2 on Ubuntu Linux. Let's say I have the following directories which represent sites that will serve content:

/srv/www/blog/          #for the blog
/srv/www/mainsite/      #for the main site

I want to set up Apache2 so that the following applies:

  1. When a user visits they are served content from /srv/www/mainsite/.
  2. When a user visits, they are served content from /srv/www/blog/.

I had thought I was going to be setting up multiple virtual hosts, but only seems to apply for distinct domains and/or IPs. What do I need to do in my apache2 configuration to achieve the above functionality?

share|improve this question
up vote 3 down vote accepted

Inside your <VirtualHost>:

DocumentRoot /srv/www/mainsite
<Directory /srv/www/mainsite>
    Order Allow,Deny
    Allow from all

Alias /blog /srv/www/blog
<Directory /srv/www/blog>
    Order Allow,Deny
    Allow from all

Ignore the directory blocks if you already have one that covers /srv/www - I just put them in to make it clear that you'll need Apache's access controls allowing access to both.

share|improve this answer
Thanks for the quick response! If this works, I'll be quite grateful and will feel a little silly that I didn't figure it out myself :-) – Ben McCormack Aug 16 '12 at 22:51
That worked! Another thing I had to do was delete the extra virtual hosts files that I had created for the same domain. I kept thinking I had a problem in my new virtualhost setup when really I just had too many files. – Ben McCormack Aug 16 '12 at 23:20

Your Answer


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.