Win7系统64位环境下使用Apache——安装Apache2.4时报错“Invalid command Order”问题的解决

时间:2022-05-25 15:21:40

之前在文章Win7系统64位环境下使用Apache——Apache2.4整合Tomcat与mod_jk提到了安装Apache2.4时有可能报错:

Invalid command ‘Order‘, perhaps misspelled or defined by a module not included
in the server configuration

这里单独说一下。

安装Apache2.4的时候,有时候会修改文件:

${Apache2.4}/conf/extra/httpd-vhosts.conf

在里面添加一些内容,比如:

<VirtualHost *:80>
    ServerName one.test.com
    JkMount /* one
    ErrorLog "logs/one-error_log"
    CustomLog "logs/one-access_log" common
</VirtualHost>

<VirtualHost *:80>
    ServerName two.test.com
    JkMount /* two
    ErrorLog "logs/two-error_log"
    CustomLog "logs/two-access_log" common
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "D:\apache-tomcat-6.0.51-file"
    ServerName   file.test.com
    ErrorLog logs/file-error_log
    CustomLog logs/file-access_log combined
    <Directory "D:\apache-tomcat-6.0.51-file">
        Require all granted
    </Directory>
</VirtualHost>

如图:

Win7系统64位环境下使用Apache——安装Apache2.4时报错“Invalid command Order”问题的解决

这里只注意第6部分,里面的:

Require all granted

表示允许全部权限,这在Apache2.2版本中是以:

Order allow,deny
Allow from all

的方式来授权的。如果在Apache2.4中也标记成了Apache2.2的形式,就会报错:

Invalid command ‘Order‘, perhaps misspelled or defined by a module not included
in the server configuration

如图:

Win7系统64位环境下使用Apache——安装Apache2.4时报错“Invalid command Order”问题的解决

所以这里要注意在Apache2.4的安装中,如果要在文件:

${Apache2.4}/conf/extra/httpd-vhosts.conf

中添加授权所有权限的命令,要使用:

Require all granted

而不是:

Order allow,deny
Allow from all

同意的道理,如果是禁止所有权限要使用:

Require all denied

而不是:

Order deny,allow
Deny from all

这里参考了:

http://systembash.com/apache-2-4-upgrade-and-the-invalid-command-order-error/

http://httpd.apache.org/docs/2.4/upgrading.html