如何在 Mac OS X 中更改 Apache2 的文档根目录

tin*_*tin 16 mac-osx apache-2.2

根据 httpd.conf,文档根目录的默认位置是/Library/WebServer/Documents. 我想要这个位置/webcontent。为此,我在 root(/) 中创建了一个 webcontent 文件夹。然后在 httpd.conf 中:

  • 将文档根行更改为 DocumentRoot /webcontent
  • 将目录标签更改为<Directory "/webcontent">;

重新启动 Apache 后,我得到以下页面:

禁止的

您无权访问 / 在此服务器上。

谁能告诉我是否需要更改其他任何地方的任何权限来更改文档根目录?

Bra*_*man 15

httpd.confOS X 提供的文件有一个默认拒绝,可以锁定每个客户端的每个目录。然后它允许访问DocumentRoot目录——这将是/Library/WebServer/Documents. 在该文件中向下翻页,您将看到:

<Directory "/Library/WebServer/Documents">
    # [...]
    Options Indexes FollowSymLinks MultiViews

    # [...]
    AllowOverride None

    # [...]
    Order allow,deny
    Allow from all

</Directory>
Run Code Online (Sandbox Code Playgroud)

"/Library/WebServer/Documents"位更改为"/webcontent",你很好。