简体   繁体   English

Apache 忽略丢失的 DocumentRoot

[英]Apache ignore missing DocumentRoot

I would like to configure my apache different.我想配置我的 apache 不同。 Now, if one of DocumentRoots is missing, all server fail to start.现在,如果缺少一个 DocumentRoots,所有服务器都无法启动。 That's annoying..真烦人..

Is there any option, how to ignore this error?有什么选择,如何忽略这个错误?

Based on the assumption that your DocumentRoot directive is used synonomously with a VirtualHost, you could separate the VirtualHosts configuration into separate conf files, place these individually into their document roots and then include them with a directory wide include directive in a generic, serverwide conf.基于您的 DocumentRoot 指令与 VirtualHost 同义使用的假设,您可以将 VirtualHosts 配置分离到单独的 conf 文件中,将它们分别放入其文档根目录中,然后将它们与目录范围的 include 指令一起包含在通用的服务器范围 conf 中。 See below for an example:请参阅下面的示例:

Create a conf in the directory below:在下面的目录中创建一个conf:

/etc/apache/sites-enabled/sites.conf

add the following添加以下内容

Include /data/www/sites/

This will include any conf file in the above directory and any subdirectory这将包括上述目录和任何子目录中的任何 conf 文件

For a host with the following DocumentRoot对于具有以下 DocumentRoot 的主机

/data/www/sites/website-one

Create a VirtualHost conf file and place it in the above directory eg:创建一个 VirtualHost conf 文件并将其放在上面的目录中,例如:

/data/www/sites/website-one/website-one.conf /data/www/sites/website-one/website-one.conf

And your conf file will contain all the information about the VirtualHost including the DocumentRoot eg并且您的 conf 文件将包含有关 VirtualHost 的所有信息,包括 DocumentRoot 例如

<VirtualHost *:80>
DocumentRoot /data/www/sites/website-one
ServerName www.website-one.com

# Other directives here

</VirtualHost>

If the DocumentRoot doesn't exist, then the conf file doesn't get loaded and the DocumentRoot directive never executed.如果 DocumentRoot 不存在,则不会加载 conf 文件,也不会执行 DocumentRoot 指令。 For security reasons be careful that your conf files don't become dereferenceable.出于安全原因,请注意您的 conf 文件不会变得不可引用。 This should probably be disabled at a server level, but it is something to be aware of.这可能应该在服务器级别禁用,但需要注意这一点。 Finally, the above pattern means that any bad conf files in the /data/www/sites directory and subdirectories will cause the server not to start.最后,上述模式意味着/data/www/sites目录和子目录中任何错误的 conf 文件都会导致服务器无法启动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM