gpt4 book ai didi

apache2 - Apache重启导致DocumentRoot必须是目录,尽管是目录而且似乎没有权限问题

转载 作者:行者123 更新时间:2023-12-02 07:31:08 25 4
gpt4 key购买 nike

我有一个几乎可以肯定是新手的问题。我本来希望在写这个问题时找到问题,但我仍然卡住了。

我想更改 apache 的 DocumentRoot,但我不断收到错误消息“DocumentRoot 必须是目录”。

情况:

  • 代码在 VMWare 虚拟机 4.0.4 build-744019 中运行
  • Linux 版本为 Scientific Linux release 6.4 (Carbon)
  • apache 的版本是 Apache/2.2.15 (Unix)(这是一个 yum 安装,没有任何内容特别)

在httpd.conf中

DocumentRoot "/home/stave/www"

当我重新启动时,我收到消息

Starting httpd: Syntax error on line 292 of /etc/httpd/conf/httpd.conf:
DocumentRoot must be a directory

迄今为止采取的步骤:

我确保该目录存在:

ls -asl /home/stave
4 drwxrwxrwx. 2 stave stave 4096 Feb 9 09:08 www
It even has a file in it "index.html", so I am very sure that the directory exists

我认为这可能是一个权限问题,所以(这是一个与互联网隔离的虚拟开发机器,我正在排除故障,所以我不太担心安全性)正如你所看到的,我将权限设置为 777。

我什至将 apache 运行的用户更改为 stave(并确认该更改适用于 ps),以确保权限不应该成为问题。

Stackoverflow

有一些堆栈溢出的答案,但大多数都说“阅读错误消息。它说该目录实际上并不存在”。其他人暗示末尾可能有一个尾部斜杠,这会很糟糕。

其他网站

我发现最有用的是 this这建议

由于 SELinux 扩展,您可能会收到“Doc​​umentRoot 必须是目录”错误,即使它实际上是一个目录。运行 system-config-securitylevel (或 redhat-c​​onfig-securitylevel)以禁用 httpd 的 SELinux 或授予 SELinux 权限目录: chcon -R -h -t httpd_sys_content_t/路径/到/目录*

我的Linux版本不是SecurityEnhancedLinux,所以在不理解的情况下我还是尝试了它:没有效果。

现状

我已经没有办法尝试了,因此任何诊断问题或建议将不胜感激

最佳答案

您在“其他网站”下发布的链接突出显示了问题的根本原因,即 Selinux。

除非服务器是 super 安全环境的一部分,否则我会简单地禁用 Selinux。

在 RedHat/CentOS/Scientific Linux 上,可以通过编辑/etc/sysconfig/selinux 轻松完成此操作 - 找到参数“selinux”并将选项“enforcing”更改为“disabled”,如下摘录所示:

# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled

进行此更改后重新启动服务器可能是明智之举。

关于apache2 - Apache重启导致DocumentRoot必须是目录,尽管是目录而且似乎没有权限问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14786881/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com