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

有这样做的命令吗?


当前回答

或者,不那么直接地说:

nmap -A localhost -p

其他回答

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"

我尝试运行命令“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

我希望这能有所帮助。

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

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

当然,在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,一旦创建了页面,在开发时就可以方便地使用(只是不要忘记在生产环境中删除它!!)