【问题标题】:Apache ignore missing DocumentRootApache 忽略缺少的 DocumentRoot
【发布时间】:2012-04-21 07:36:52
【问题描述】:

我想配置我的 apache 不同。现在,如果缺少 DocumentRoots 之一,则所有服务器都无法启动。好烦啊。。

有什么办法,如何忽略这个错误?

【问题讨论】:

    标签: apache ubuntu configuration


    【解决方案1】:

    基于您的 DocumentRoot 指令与 VirtualHost 同义使用的假设,您可以将 VirtualHosts 配置分离到单独的 conf 文件中,将它们单独放置到它们的文档根目录中,然后将它们包含在通用目录范围内的 include 指令中,服务器范围的conf。请参阅下面的示例:

    在下面的目录中创建一个conf:

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

    添加以下内容

    Include /data/www/sites/
    

    这将包括上述目录和任何子目录中的任何 conf 文件

    对于具有以下 DocumentRoot 的主机

    /data/www/sites/website-one
    

    创建一个VirtualHost conf文件并将其放在上面的目录中例如:

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

    您的 conf 文件将包含有关 VirtualHost 的所有信息,包括 DocumentRoot,例如

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

    如果 DocumentRoot 不存在,则不会加载 conf 文件并且不会执行 DocumentRoot 指令。出于安全原因,请注意不要让您的 conf 文件变得可取消引用。这可能应该在服务器级别禁用,但需要注意。最后,上述模式意味着/data/www/sites目录和子目录中任何错误的conf文件都会导致服务器无法启动。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-01-28
      • 2015-03-18
      • 2015-09-22
      • 1970-01-01
      • 1970-01-01
      • 2022-08-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多