首页 > 解决方案 > Apache 设置:指令需要额外的参数

问题描述

我正在尝试在 macOS 上使用 Apache(仅限本地主机)。当我这样做时,apachectl configtest我得到以下响应:

AH00526: Syntax error on line 238 of /private/etc/apache2/httpd.conf:
<Directory> directive requires additional arguments

httpd.conf 文件的对应部分是

DocumentRoot ~/Sites
<Directory />
 Options Indexes SymLinks
 MultiviewsMatch Any
 AllowOverride None
 Require all granted
</Directory>

我查阅了几个论坛/Apache 文档,但我看不到错误。有谁知道如何解决这个问题?

标签: apache

解决方案


通过编写<Directory />,您是在告诉 Apache Directory 标签会立即关闭。所以你放的配置相当于

<Directory>
</Directory>

 Options Indexes SymLinks
 MultiviewsMatch Any
 AllowOverride None
 Require all granted
</Directory>

因为“/>”终止了“<Directory”标签。

以这种方式修改它:

<Directory "/">
 Options Indexes SymLinks
 MultiviewsMatch Any
 AllowOverride None
 Require all granted
</Directory>

请注意,“/”将是您机器的“/”。因此,您正在通过 Apache 授予对系统上“/”的访问权限...


推荐阅读