无效的命令"Order",可能由服务器配置中未包含的模块拼写错误或定义失败

thu*_*inh 33 linux apache

当我尝试启动或重新启动我的apache服务器时,我得到以下消息:

Syntax error on line 162 of /etc/apache2/apache2.conf:
Invalid command 'Order', perhaps misspelled or defined by a module not included in the server configuration
Action 'configtest' failed.
The Apache error log may have more information.
 failed!
Run Code Online (Sandbox Code Playgroud)

我尝试在谷歌上找到此错误并修复它:

http://linuxindetails.wordpress.com/2009/12/02/invalid-command-order-perhaps-misspelled-or-defined-by-a-module-not-included-in-the-server-configuration-failed/

我收到错误: Module authz_host does not exist!

那么,有些身体帮我解决了吗?

谢谢 !

小智 50

从openSUSE 13.2升级到openSUSE Leap 42.1时,我遇到了同样的问题.

问题不在于apache2-configuration中缺少模块.

问题是从apache 2.2升级到apache 2.4."订单"和"允许"必须重写如下(示例):

在2.2中:

Order allow,deny
Allow from all
Run Code Online (Sandbox Code Playgroud)

在2.4中:

Require all granted
Run Code Online (Sandbox Code Playgroud)

您可以在此处找到更多选项示例: 升级apache2

  • 请注意,[mod_access_compat](https://httpd.apache.org/docs/2.4/mod/mod_access_compat.html) 可用于无法升级配置的情况。 (2认同)

小智 22

在SUSE 12上,authz_host已经启用,所以我需要关注willoller的注释并启用mod_access_compat:

a2enmod mod_access_compat
service apache2 restart
Run Code Online (Sandbox Code Playgroud)


小智 18

您需要启用该authz_host模块.以下是该模块的Apache文档.

我不确定你使用的Linux发行版,但这里有一些例子.

Ubuntu的:

sudo a2enmod authz_host
sudo service apache2 restart
Run Code Online (Sandbox Code Playgroud)

RHEL:

vi /etc/httpd/conf/httpd.conf

# Make sure this line is not commented:
...
LoadModule authz_host_module modules/mod_authz_host.so
...
Run Code Online (Sandbox Code Playgroud)

  • 使用apache 2.4,您可能还需要`mod_access_compat`. (19认同)

小智 18

使用Apache 2.4,请取消注释/添加以下模块:

LoadModule access_compat_module modules/mod_access_compat.so
LoadModule authz_host_module modules/mod_authz_host.so
Run Code Online (Sandbox Code Playgroud)