我现在在Mac OS 10.9.2中将本地环境设置为虚拟主机。我正在从另一个configuration中复制这个虚拟主机。 我的问题是,DocumentRoot和Directory之间有什么区别,他们必须匹配吗? 我必须在我的VirtualHostconfiguration中包含目录吗?
<VirtualHost *:80> DocumentRoot "/Users/memyselfandi/websites/prestashop16.dev" ServerName prestashop16.dev ErrorLog "/private/var/log/apache2/prestashop16.local-error_log" CustomLog "/private/var/log/apache2/prestashop16.local-access_log" common <Directory "/Users/memyselfandi/websites/workspace/dev"> AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost>
DocumentRoot是Web服务器的位置,如果用户访问http://prestashop16.dev/,Web服务器将从该位置提供文件。 所有的网页可见文件应该在或低于该文件夹的级别。
目录块允许您指定只应用于特定目录的Apacheconfiguration规则。
两者不需要匹配,并且可以根据Apache文档将<Directory>块放置在VirtualHost块或通用服务器configuration中。
另外,您可以有多个目录块。 例如,如果你的DocumentRoot是var/www并且你想限制访问/var/www/private你可以创build<Directory /var/www/private></Directory>块,并把你想要的安全configuration放在那里而不会影响其他文件夹。