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

有这样做的命令吗?


试试apachectl -V:

$ apachectl -V
Server version: Apache/2.2.9 (Unix)
Server built:   Sep 18 2008 21:54:05
Server's Module Magic Number: 20051115:15
Server loaded:  APR 1.2.7, APR-Util 1.2.7
Compiled using: APR 1.2.7, APR-Util 1.2.7
... etc ...

如果不成功,请使用sudo命令运行该命令。

或者,不那么直接地说:

nmap -A localhost -p

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

对于更新的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....

这适用于我的Debian:

$ /usr/sbin/apache2 -v

对我来说,这适用于Debian 6(挤压):

Linux www809 2.6.26-2-xen-686 #1 SMP Wed Sep 21 09:56:47 UTC 2011 i686 GNU/Linux

我必须走上正确的道路:

/usr/local/apache/bin** $ **./apachectl -v

./apachectl:第71行:ulimit:打开文件:不能修改limit:不允许操作 服务器版本:Apache/2.2.21 (Unix) 服务器构建:2011年12月17日19:57:53

用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....

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

httpd -V

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

dpkg -l | grep apache

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

另一种方法是在基于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

我尝试运行命令“httpd -V”和“apachectl -V”,但我无法执行,并得到错误:

-ksh: php: not found[没有这样的文件或目录]

然后我尝试了另一种方法。我进入服务器上的Apache目录,然后尝试执行命令:

./apachectl -v

这为我工作,并返回输出:

Server version: Apache/2.2.20 (Unix)
Server built:   Sep  6 2012 17:22:16

我希望这能有所帮助。

该命令取决于您的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
dlocate -s apache2 | grep '^Version:'

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

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

You can use apachectl -V or apachectl -v. Both of them will return the Apache version information! xgqfrms:~/workspace $ apachectl -v Server version: Apache/2.4.7 (Ubuntu) Server built: Jul 15 2016 15:34:04 xgqfrms:~/workspace $ apachectl -V Server version: Apache/2.4.7 (Ubuntu) Server built: Jul 15 2016 15:34:04 Server's Module Magic Number: 20120211:27 Server loaded: APR 1.5.1-dev, APR-UTIL 1.5.3 Compiled using: APR 1.5.1-dev, APR-UTIL 1.5.3 Architecture: 64-bit Server MPM: prefork threaded: no forked: yes (variable process count) Server compiled with.... -D APR_HAS_SENDFILE -D APR_HAS_MMAP -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled) -D APR_USE_SYSVSEM_SERIALIZE -D APR_USE_PTHREAD_SERIALIZE -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT -D APR_HAS_OTHER_CHILD -D AP_HAVE_RELIABLE_PIPED_LOGS -D DYNAMIC_MODULE_LIMIT=256 -D HTTPD_ROOT="/etc/apache2" -D SUEXEC_BIN="/usr/lib/apache2/suexec" -D DEFAULT_PIDLOG="/var/run/apache2.pid" -D DEFAULT_SCOREBOARD="logs/apache_runtime_status" -D DEFAULT_ERRORLOG="logs/error_log" -D AP_TYPES_CONFIG_FILE="mime.types" -D SERVER_CONFIG_FILE="apache2.conf" You may be more like using apache2 -V or apache2 -v. It seems easier to remember! xgqfrms:~/workspace $ apache2 -v Server version: Apache/2.4.7 (Ubuntu) Server built: Jul 15 2016 15:34:04 xgqfrms:~/workspace $ apache2 -V Server version: Apache/2.4.7 (Ubuntu) Server built: Jul 15 2016 15:34:04 Server's Module Magic Number: 20120211:27 Server loaded: APR 1.5.1-dev, APR-UTIL 1.5.3 Compiled using: APR 1.5.1-dev, APR-UTIL 1.5.3 Architecture: 64-bit Server MPM: prefork threaded: no forked: yes (variable process count) Server compiled with.... -D APR_HAS_SENDFILE -D APR_HAS_MMAP -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled) -D APR_USE_SYSVSEM_SERIALIZE -D APR_USE_PTHREAD_SERIALIZE -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT -D APR_HAS_OTHER_CHILD -D AP_HAVE_RELIABLE_PIPED_LOGS -D DYNAMIC_MODULE_LIMIT=256 -D HTTPD_ROOT="/etc/apache2" -D SUEXEC_BIN="/usr/lib/apache2/suexec" -D DEFAULT_PIDLOG="/var/run/apache2.pid" -D DEFAULT_SCOREBOARD="logs/apache_runtime_status" -D DEFAULT_ERRORLOG="logs/error_log" -D AP_TYPES_CONFIG_FILE="mime.types" -D SERVER_CONFIG_FILE="apache2.conf"

当然,在shell中输入/usr/sbin/apache2 -v是最好和最快的方法,顺便说一下,这里还有另一种选择,以防你的服务器中也有PHP,你有兴趣在快速编程步骤中收集Apache版本(以及更多信息)。

在你的Apache web根文件夹(或任何你喜欢的文件夹)中创建一个info.php文件,并在里面写这些:

<?php
    phpinfo();
?>

现在转到yoursite.com/info.php(或localhost/info.php用于本地计算机)。

你会在PHP变量部分看到你的Apache版本,这里有一个例子:

Phpinfo()示例转储页面

另外,请注意,这些步骤显然适用于任何与PHP集成的web服务器,所以它并不局限于Apache,一旦创建了页面,在开发时就可以方便地使用(只是不要忘记在生产环境中删除它!!)

我认为您必须确定您有二进制文件或源文件的安装类型。 要检查安装了哪些二进制包:具有root权限执行以下命令:

dpkg -l |grep apache2

结果应该是这样的:

dpkg -l |grep apache2
ii  apache2                               2.4.10-10+deb8u8                      amd64        Apache HTTP Server
ii  apache2-bin                           2.4.10-10+deb8u8                      amd64        Apache HTTP Server (modules and other binary files)
ii  apache2-data                          2.4.10-10+deb8u8                      all          Apache HTTP Server (common files)
ii  apache2-doc                           2.4.10-10+deb8u8                      all          Apache HTTP Server (on-site documentation)

要查找版本,您可以运行:

apache2ctl -V |grep -i "Server version"

结果应该是这样的: 服务器版本:Apache/2.4.10 (Debian)

工作在debian11靶心

/usr/sbin/apache2 -v