Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache主文档根不';不存在_Apache_Document Root - Fatal编程技术网

Apache主文档根不';不存在

Apache主文档根不';不存在,apache,document-root,Apache,Document Root,我试图找到在我的Apache配置中仍然存在对/var/www/html的引用。当我运行apache2ctl-S时,它会显示Main DocumentRoot:“/var/www/html”,但我的虚拟主机或主Apache配置文件都没有指向该目录 我尝试过使用grep-r“var/www/html”/etc/apache2/搜索所有配置文件,但它没有返回任何结果 在我的/etc/apache2/apache2.conf文件中没有该路径的条目(有一个用于/var/www的条目,我在其中存储虚拟主机)

我试图找到在我的Apache配置中仍然存在对
/var/www/html
的引用。当我运行
apache2ctl-S
时,它会显示
Main DocumentRoot:“/var/www/html”
,但我的虚拟主机或主Apache配置文件都没有指向该目录

我尝试过使用
grep-r“var/www/html”/etc/apache2/
搜索所有配置文件,但它没有返回任何结果

在我的
/etc/apache2/apache2.conf
文件中没有该路径的
条目(有一个用于
/var/www
的条目,我在其中存储虚拟主机)

这种配置怪癖困扰着我的OCD,但我也经常在Apache错误日志中看到以下条目:

[Fri Jun 28 18:19:53.424619 2019] [autoindex:error] [pid 22665] 
[client 209.222.82.167:47376] AH01276: Cannot serve directory
   /var/www/html/: No matching DirectoryIndex 
   (default.php,index.php,index.html,index.htm) found, and server-generated
   directory index forbidden by Options directive
Apache如何决定主documentroot是什么,我如何更改它

编辑:

对于可用的站点/启用的站点,我有四个文件,
000 default.conf
000 default le ssl.conf
000 www default.conf
,和
000 www default le ssl.conf
000 default.conf
是certbot设置的指向https站点的重定向,没有DocumentRoot指令。
000 www default.conf
000 default.conf
相同,但服务器名(一个有www,另一个没有);对于
000 www default le.conf
000 default le.conf
,也遵循相同的模式

以下是我尝试过的一些东西的输出:

  • apache2ctl-V
  • apache2ctl-S
  • $sudo grep-r”/var/www/html/
    (部分,我在将近5个小时后停止):

在Debian/Ubuntu中,默认的虚拟主机文件:/etc/apache2/sites available/000 default.conf具有文档根/var/www/html


我认为apache2ctl-S报告的主DocumentRoot与默认DocumentRoot相同。默认DocumentRoot在/etc/apache2/apache2.conf/etc/apache2/sites available/000 default.conf中定义。这在中进行了描述。因此,要更改主DocumentRoot,您需要编辑/etc/apache2/sites available/000 default.conf

,正如@Nic3500所指出的,
/var/www/html
是主DocumentRoot的默认值。更改虚拟主机配置不会影响这一点。但是,将DocumentRoot指令添加到
apache.conf
中确实会改变它,这反映在
apache2ctl-S
的输出中

换句话说,我的主DocumentRoot未配置,在全局配置文件中明确定义之前一直使用默认值。

指令Apache的文档明确了其默认值:

默认值:DocumentRoot“/usr/local/apache/htdocs”

表示Apache在任何地方未指定任何人时给出的值:

如果指令有一个默认值(即,如果您从 整个配置,apacheweb服务器的行为就像 将其设置为特定值


是的,我知道/usr/local/apache/htdocs与您的值不同/var/www/html,但这只是一个小细节,取决于apache构建的linux发行版。

检查
apachectl-V
以确认您正在查看的配置文件是正确的。我编辑了问题以包含
apachectl-V
-S
的/var/www/html的输出是编译时使用的值,因此它是默认值。你不能改变它。如果您将DocumentRoot设置为另一个值,它将使用该值。@Nic3500,看起来您可能找到了什么。我检查了我拥有的另外三台apache服务器,它们都没有使用/var/www/html,所有这些服务器都为每个虚拟主机配置了documentroot,ApacheCtl-S将其显示为所有服务器的主documentroot。我编辑了我的问题,并提供了有关配置文件的更多信息。在本例中,它不是在000-default.conf中设置的,并且我的conf文件中没有引用该目录。.要找出哪个虚拟主机配置为使用DocumentRoot:/var/www/html,请运行命令:grep”/var/www/html”/etc/apache2-RI;如果您这样做了,它将不返回任何内容;我在整个磁盘驱动器中搜索该字符串,但它没有出现在任何apache配置文件中。