Apache:具有多个文档根目录的多个位置的虚拟主机:有可能吗?

好吧,这是我的问题:我已经设置了一个适当的服务器名称的虚拟主机。 例如,我也在同一台机器上安装了Squirrelmail和SVN。 我想通过键入http:// mydomain进入默认页面,通过inputhttp:// mydomain.no-ip.org/svn键入http:// mydomain / mail和我的svn来到我的邮件前端。

我的虚拟主机定义如下:

<VirtualHost *:80> ServerName mydomain.no-ip.org #Default site, accessible by http :// mydomain.no-ip.org/ <Location /> DocumentRoot "/var/www/alias" DirectoryIndex index.php </Location> #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> <IfModule mod_dir.c> DirectoryIndex index.php </IfModule> <Files configtest.php> order deny,allow deny from all allow from 127.0.0.1 </Files> </Location> #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 </Location> 

但是,这个问题是存在的。 当试图重新启动apache时,它说你不能在一个Location定义一个DocumentRoot 。 因此,我做错了什么,但我还不知道究竟是什么。

当浏览serverfaultfind有人有类似的问题,我find了一个链接到Apache的虚拟主机的例子: http ://httpd.apache.org/docs/2.0/vhosts/examples.html,hovever,我不能那么哪个例子是最好的。

说实话,我也不是精通apache,而是方式,所以我知道我刚刚写的东西可能对你来说,充其量是荒谬的。

那么,有谁知道如何解决我的问题? 任何帮助将不胜感激!

事实上,你不能拥有另一个DocumentRoot ; 你会想要一个Alias

<Location>块中删除DocumentRoot ,并将其replace为(它必须位于<Location>块之外):

 Alias /mail /usr/share/squrrelmail 

让我们将这些SquirrelMail设置应用到目录而不是位置; 只要换掉块的顶部和底部的定义:

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

另外,在SquirrelMail目录的任何位置都不可能有任何权限设置。 您可能需要在<Directory /usr/share/squrrelmail>部分中使用此类或类似内容:

 Order Allow,Deny Allow from all 
  1. 不要将虚拟主机用于单个主机,请configuration“Man Server”部分
  2. 阅读关于Alias指令