如何查看Debian机器上安装了Apache的哪个版本?
有这样做的命令吗?
如何查看Debian机器上安装了Apache的哪个版本?
有这样做的命令吗?
当前回答
工作在debian11靶心
/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
我使用红帽Linux和以下命令工作:
httpd -V
该命令取决于您的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
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