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

有这样做的命令吗?


当前回答

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

我希望这能有所帮助。

其他回答

试试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命令运行该命令。

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

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

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

dpkg -l | grep apache

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

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

我希望这能有所帮助。