Ok, so here's my problem: I've set up myself a virtualhost with an appropriate server name. I also have, for example, Squirrelmail and SVN installed on the same machine. I want to get to the default page by typing http :// mydomain , get to my mail frontend by typing http ://mydomain /mail and to my svn by typing http :// mydomain.no-ip.org /svn.

Heres my vhost definition:

<VirtualHost *:80>

ServerName mydomain.no-ip.org

#Default site, accessible by http :// mydomain.no-ip.org/
<Location />
    DocumentRoot "/var/www/alias"   
    DirectoryIndex index.php

#Squirrelmail, accessible by http :// mydomain.no-ip.org /mail  
<Location /mail>
    DocumentRoot /usr/share/squrrelmail     
    Options FollowSymLinks
    <IfModule mod_php5.c>
            php_flag register_globals off
    <IfModule mod_dir.c>
         DirectoryIndex index.php
    <Files configtest.php>
            order deny,allow
            deny from all
            allow from

#SVN, accessible by http :// mydomain.no-ip.org /svn
<Location /svn>
    DAV svn
    SVNParentPath "/svnrepo"
    SVNListParentPath On
    AuthType Basic
    AuthName "My SVN Repo"
    AuthUserFile "/svnrepo/htpasswd"
    Require valid-user

However, there's a problem with that one; when trying to restart apache, it says that you can't define a DocumentRoot within a Location. Therefore, there's something that I'm doing wrong, but I don't yet know what exactly.

When browsing serverfault to find if anybody had a similar problem, I've found a link to Apache's vhost examples: http://httpd.apache.org/docs/2.0/vhosts/examples.html , hovever, I can't figure out which example would be the best one there.

To be honest, neither am I versed in apache and it's ways, so I know what I've just written may be, to you, nonsensical at best.

So, anybody knows how to solve my problem, please? Any help would be greatly appreciated!

2 Answers 2


Indeed, you cannot have another DocumentRoot; you'll want an Alias instead.

Drop the DocumentRoot from the <Location> block, and replace it with this (which must be outside the <Location> block):

Alias /mail /usr/share/squrrelmail

And let's apply those SquirrelMail settings to the directory instead of the location; just swap out the definitions at the top and bottom of the block:

<Directory /usr/share/squrrelmail>
    Options FollowSymLinks
    <IfModule mod_php5.c>
            php_flag register_globals off
    # etc

Also, it's unlikely that there's any permissions settings anywhere that apply to the SquirrelMail directory. You'll probably need this or similar in the <Directory /usr/share/squrrelmail> section:

Order Allow,Deny
Allow from all
  1. Don't use virtualhosts for single host, configure "Man server" part
  2. Read about Alias directive
  • 1
    Why shouldn't you use a virtual host for a single-site server? Do you have any evidence that it does soothing related to performance or anything else? I ask, because it is far easier to add a second virtual host next month, when you find out you have to support an additional domain, if you already have virtual hosting setup.
    – Zoredache
    Feb 24, 2012 at 0:11
  • @Zoredache - because "Okkam Razor" exist. And when and if I'll want virtualhosts, I'll just add mod_vhost_alias instead of VirtualHost containers headache Feb 24, 2012 at 0:23
  • @LazyBadger Huh? mod_vhost_alias only covers a tiny, tiny subset of the use cases for vhosts. Feb 24, 2012 at 0:39
  • I don't think Occam's razor really applies here it is about finding a simple explanation. On many Linux distributions the default configurations use virtual hosts by default (Debian-based). On those distros it would be more work, to remove all the virtual hosting config, and if you did, then your configuration would diverge from the package quite a bit making upgrading more difficult. A pragmatic approach would be to not work against how your distro does things by default unless you have a good reason.
    – Zoredache
    Feb 24, 2012 at 0:40
  • Lazy badger is right, there's no point in using virtual hosts for a single server unless you are planing on adding multiple domains later and you want to allow for expansion that way. Use aliases, that's all you need really. Doing what you're doing now is like having one host with a single virtual guest on it when you know there won't ever be any more on it. Feb 24, 2012 at 1:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .