如何查看Debian机器上安装了Apache的哪个版本?

有这样做的命令吗?


当前回答

Apache的一些安装是fubar(想想Oracle对它的包装,OHS),不理解-V标志,也不能直接调用而不会遇到丢失库错误。

最简单的方法是在httpd二进制文件和grep上使用strings命令(binutils的一部分)来获取可能类似于版本的字符串。例如,假设你的httpd二进制文件在目录/foo/bar下:

$ strings /foo/bar/httpd  | grep 2.2
GLIBC_2.2.5
Oracle-HTTP-Server/2.2.22 (Unix)
Success_Accepted_202
202 Accepted

大多数二进制文件(不是全部)以静态字符串的形式包含它们的版本(至少是主版本)。这是我获取版本的常用方法(或者用来证实二进制的帮助信息与实际情况是否相符)。

其他回答

这适用于我的Debian:

$ /usr/sbin/apache2 -v

你也可以直接使用包管理器:

dpkg -l | grep apache

这不仅仅关注于版本号,而是会进行更广泛的搜索,这将为您提供其他有用的信息,比如模块版本。

对于更新的Debian或Ubuntu发行版,应该使用apache2ctl -v或apache2 -v。

apache:/etc/apache2# apache2ctl -v
Server version: Apache/2.2.16 (Debian)
Server built:   May 12 2011 11:58:18

或者您可以使用apache2 -V获取更多信息。

apache2 -V
Server version: Apache/2.2.16 (Debian)
Server built:   May 12 2011 11:58:18
Server's Module Magic Number: x
Server loaded:  APR 1.4.2, APR-Util 1.3.9
Compiled using: APR 1.2.12, APR-Util 1.3.9
Architecture:   64-bit
Server MPM:     Worker
  threaded:     yes (fixed thread count)
    forked:     yes (variable process count)
Server compiled with....

我使用红帽Linux和以下命令工作:

httpd -V

用sudo试试

apachectl -V
-bash: apachectl: command not found

sudo apachectl -V
Server version: Apache/2.4.6 (Debian)
Server built:   Aug 12 2013 18:20:23
Server's Module Magic Number: 20120211:24
Server loaded:  APR 1.4.8, APR-UTIL 1.5.3
Compiled using: APR 1.4.8, APR-UTIL 1.5.2
Architecture:   32-bit
Server MPM:     prefork
  threaded:     no
  forked:     yes (variable process count)
Server compiled with....
bla bla....