检测Apache的版本在Apache的配置? [英] Detect Apache version in apache config?

查看:191
本文介绍了检测Apache的版本在Apache的配置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TL;博士:我要如何做以下的的.conf或.htaccess文件:

tl;dr: How do I do the following in a .conf or .htaccess file:

<IfApache22>
  # Do A
</IfApache22>
<IfApache24>
  # Do B
</IfApache24>

较长的问题:

使用的Apache 2.4的老订单得到的德precated赞成需要的。

With Apache 2.4 the old Order get's deprecated in favor of Require.

在我的.htaccess文件我有

In my .htaccess files I have

<FilesMatch "\.(long|list|file|types)$">
  Order allow,deny
</FilesMatch>

这意味着阿帕奇无法启动,除非我能 access_compat 。这样做虽然presents一个有用的解决办法,我想一个解决方案,既语法的工作原理的配置将被分发到很多的服务器。现在的问题是我怎么能检测的Apache的当前版本和应用正确的指令。

which means Apache fails to start unless I enable access_compat. While doing so presents a useful workaround, I want a solution that works with both syntaxes as the config will be distributed to a lot of servers. The question is how I can detect the current version of Apache and apply the correct directive.

我打算使用的文件被分配到和使用的很多人的框架,我无法控制/保证他们有或没有任何特定的服务器设置,这就是为什么我想要的文件是2.2 / 2.4不可知论。

I intend to use the file for a framework that is distributed to and used by a lot of people, and I can't control/guarantee that they have or lack any particular server setup, which is why I'd like the file to be 2.2/2.4 "agnostic".

推荐答案

这是我所使用的黑客。

# Apache 2.2
<IfModule !mod_authz_core.c>
    Satisfy Any
</IfModule>

# Apache 2.4
<IfModule mod_authz_core.c>
    Require all granted
</IfModule>

这篇关于检测Apache的版本在Apache的配置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆