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

有这样做的命令吗?


当前回答

该命令取决于您的Linux版本如何命名Apache Server。

在Debian和Mac OS上:

apachectl -v

在Red Hat和Amazon的EC2 Linux上使用:

httpd -v

在其他版本的Linux上尝试:

apache2 -v

你可以使用两种不同的标志:

-v # gives you the version number
-V # gives you the compile settings including version number.

如果你想在完整目录下运行命令,比如user3786265,但不知道你的apache位于哪里,使用whereis命令:

whereis httpd

其他回答

对我来说,apachectl -V不起作用,但apachectl fullstatus给了我我的版本。

这适用于我的Debian:

$ /usr/sbin/apache2 -v

另一种方法是在基于debian的系统上检查包(包括Apache)安装的版本,我们可以使用:

apt-cache policy <package_name>

例如Apache

apt-cache policy apache2

它将显示如下内容(查看Installed行):

$ apt-cache policy apache2
apache2:
  Installed: (none)
  Candidate: 2.2.22-1ubuntu1.9
  Version table:
     2.2.22-1ubuntu1.9 0
        500 http://hk.archive.ubuntu.com/ubuntu/ precise-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu/ precise-security/main amd64 Packages
     2.2.22-1ubuntu1 0
        500 http://hk.archive.ubuntu.com/ubuntu/ precise/main amd64 Packages

或者,不那么直接地说:

nmap -A localhost -p

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

dpkg -l | grep apache

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