[apache] Version of Apache installed on a Debian machine

How can I check which version of Apache is installed on a Debian machine?

Is there a command for doing this?

This question is related to apache debian version

The answer is


dlocate -s apache2 | grep '^Version:'

Another way round to check a package (including Apache) installed version on Debian-based system, we can use:

apt-cache policy <package_name>

e.g. for Apache

apt-cache policy apache2

which will show something like (look at the Installed line):

$ 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

For me apachectl -V did not work, but apachectl fullstatus gave me my version.


  1. You can use apachectl -V or apachectl -v. Both of them will return the Apache version information!

    _x000D_
    _x000D_
        xgqfrms:~/workspace $ apachectl -v_x000D_
    _x000D_
        Server version: Apache/2.4.7 (Ubuntu)_x000D_
        Server built:   Jul 15 2016 15:34:04_x000D_
    _x000D_
    _x000D_
        xgqfrms:~/workspace $ apachectl -V_x000D_
    _x000D_
        Server version: Apache/2.4.7 (Ubuntu)_x000D_
        Server built:   Jul 15 2016 15:34:04_x000D_
        Server's Module Magic Number: 20120211:27_x000D_
        Server loaded:  APR 1.5.1-dev, APR-UTIL 1.5.3_x000D_
        Compiled using: APR 1.5.1-dev, APR-UTIL 1.5.3_x000D_
        Architecture:   64-bit_x000D_
        Server MPM:     prefork_x000D_
          threaded:     no_x000D_
            forked:     yes (variable process count)_x000D_
        Server compiled with...._x000D_
         -D APR_HAS_SENDFILE_x000D_
         -D APR_HAS_MMAP_x000D_
         -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)_x000D_
         -D APR_USE_SYSVSEM_SERIALIZE_x000D_
         -D APR_USE_PTHREAD_SERIALIZE_x000D_
         -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT_x000D_
         -D APR_HAS_OTHER_CHILD_x000D_
         -D AP_HAVE_RELIABLE_PIPED_LOGS_x000D_
         -D DYNAMIC_MODULE_LIMIT=256_x000D_
         -D HTTPD_ROOT="/etc/apache2"_x000D_
         -D SUEXEC_BIN="/usr/lib/apache2/suexec"_x000D_
         -D DEFAULT_PIDLOG="/var/run/apache2.pid"_x000D_
         -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"_x000D_
         -D DEFAULT_ERRORLOG="logs/error_log"_x000D_
         -D AP_TYPES_CONFIG_FILE="mime.types"_x000D_
         -D SERVER_CONFIG_FILE="apache2.conf"
    _x000D_
    _x000D_
    _x000D_

  2. You may be more like using apache2 -V or apache2 -v. It seems easier to remember!

    _x000D_
    _x000D_
        xgqfrms:~/workspace $ apache2 -v_x000D_
    _x000D_
        Server version: Apache/2.4.7 (Ubuntu)_x000D_
        Server built:   Jul 15 2016 15:34:04_x000D_
    _x000D_
    _x000D_
        xgqfrms:~/workspace $ apache2 -V_x000D_
    _x000D_
        Server version: Apache/2.4.7 (Ubuntu)_x000D_
        Server built:   Jul 15 2016 15:34:04_x000D_
        Server's Module Magic Number: 20120211:27_x000D_
        Server loaded:  APR 1.5.1-dev, APR-UTIL 1.5.3_x000D_
        Compiled using: APR 1.5.1-dev, APR-UTIL 1.5.3_x000D_
        Architecture:   64-bit_x000D_
        Server MPM:     prefork_x000D_
          threaded:     no_x000D_
            forked:     yes (variable process count)_x000D_
        Server compiled with...._x000D_
         -D APR_HAS_SENDFILE_x000D_
         -D APR_HAS_MMAP_x000D_
         -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)_x000D_
         -D APR_USE_SYSVSEM_SERIALIZE_x000D_
         -D APR_USE_PTHREAD_SERIALIZE_x000D_
         -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT_x000D_
         -D APR_HAS_OTHER_CHILD_x000D_
         -D AP_HAVE_RELIABLE_PIPED_LOGS_x000D_
         -D DYNAMIC_MODULE_LIMIT=256_x000D_
         -D HTTPD_ROOT="/etc/apache2"_x000D_
         -D SUEXEC_BIN="/usr/lib/apache2/suexec"_x000D_
         -D DEFAULT_PIDLOG="/var/run/apache2.pid"_x000D_
         -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"_x000D_
         -D DEFAULT_ERRORLOG="logs/error_log"_x000D_
         -D AP_TYPES_CONFIG_FILE="mime.types"_x000D_
         -D SERVER_CONFIG_FILE="apache2.conf"
    _x000D_
    _x000D_
    _x000D_


You can also use the package manager directly:

dpkg -l | grep apache

This isn't focused on just version number, but it will make a broader search, which will give you other useful information, like module versions.


For me apachectl -V did not work, but apachectl fullstatus gave me my version.


Or, less directly:

nmap -A localhost -p 80


For me apachectl -V did not work, but apachectl fullstatus gave me my version.


The command varies depending on how your version of Linux has named the Apache Server.

On Debian and Mac OS:

apachectl -v

On Red Hat and Amazon's EC2 Linux use:

httpd -v

On other verisons of Linux try:

apache2 -v

You can use two different flags:

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

If you want to run the command with the full directory like user3786265 did but don't know where your apache is located, use the whereis command:

whereis httpd

dlocate -s apache2 | grep '^Version:'

I am using Red Hat Linux and the following command works:

httpd -V

I tried running the command "httpd -V" and "apachectl -V", but I could not execute and was getting the error:

-ksh: php: not found [No such file or directory]

Then I tried another way. I went to the Apache directory on my server and then tried executing the command:

./apachectl -v

This worked for me and returned the output:

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

I hope this helps.


You should use apache2ctl -v or apache2 -v for newer Debian or Ubuntu distributions.

apache:/etc/apache2# apache2ctl -v
Server version: Apache/2.2.16 (Debian)
Server built:   May 12 2011 11:58:18

or you can use apache2 -V to get more information.

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

I think you have to be sure what type of installation you have binary or source. To check what binary packages is installed: with root rights execute following command:

dpkg -l |grep apache2

result should be something like:

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)

To find version you can run :

apache2ctl -V |grep -i "Server version"

result should be something like: Server version: Apache/2.4.10 (Debian)


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

If it does not work for you, run the command with sudo.


I tried running the command "httpd -V" and "apachectl -V", but I could not execute and was getting the error:

-ksh: php: not found [No such file or directory]

Then I tried another way. I went to the Apache directory on my server and then tried executing the command:

./apachectl -v

This worked for me and returned the output:

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

I hope this helps.


Or, less directly:

nmap -A localhost -p 80


I am using Red Hat Linux and the following command works:

httpd -V

  1. You can use apachectl -V or apachectl -v. Both of them will return the Apache version information!

    _x000D_
    _x000D_
        xgqfrms:~/workspace $ apachectl -v_x000D_
    _x000D_
        Server version: Apache/2.4.7 (Ubuntu)_x000D_
        Server built:   Jul 15 2016 15:34:04_x000D_
    _x000D_
    _x000D_
        xgqfrms:~/workspace $ apachectl -V_x000D_
    _x000D_
        Server version: Apache/2.4.7 (Ubuntu)_x000D_
        Server built:   Jul 15 2016 15:34:04_x000D_
        Server's Module Magic Number: 20120211:27_x000D_
        Server loaded:  APR 1.5.1-dev, APR-UTIL 1.5.3_x000D_
        Compiled using: APR 1.5.1-dev, APR-UTIL 1.5.3_x000D_
        Architecture:   64-bit_x000D_
        Server MPM:     prefork_x000D_
          threaded:     no_x000D_
            forked:     yes (variable process count)_x000D_
        Server compiled with...._x000D_
         -D APR_HAS_SENDFILE_x000D_
         -D APR_HAS_MMAP_x000D_
         -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)_x000D_
         -D APR_USE_SYSVSEM_SERIALIZE_x000D_
         -D APR_USE_PTHREAD_SERIALIZE_x000D_
         -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT_x000D_
         -D APR_HAS_OTHER_CHILD_x000D_
         -D AP_HAVE_RELIABLE_PIPED_LOGS_x000D_
         -D DYNAMIC_MODULE_LIMIT=256_x000D_
         -D HTTPD_ROOT="/etc/apache2"_x000D_
         -D SUEXEC_BIN="/usr/lib/apache2/suexec"_x000D_
         -D DEFAULT_PIDLOG="/var/run/apache2.pid"_x000D_
         -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"_x000D_
         -D DEFAULT_ERRORLOG="logs/error_log"_x000D_
         -D AP_TYPES_CONFIG_FILE="mime.types"_x000D_
         -D SERVER_CONFIG_FILE="apache2.conf"
    _x000D_
    _x000D_
    _x000D_

  2. You may be more like using apache2 -V or apache2 -v. It seems easier to remember!

    _x000D_
    _x000D_
        xgqfrms:~/workspace $ apache2 -v_x000D_
    _x000D_
        Server version: Apache/2.4.7 (Ubuntu)_x000D_
        Server built:   Jul 15 2016 15:34:04_x000D_
    _x000D_
    _x000D_
        xgqfrms:~/workspace $ apache2 -V_x000D_
    _x000D_
        Server version: Apache/2.4.7 (Ubuntu)_x000D_
        Server built:   Jul 15 2016 15:34:04_x000D_
        Server's Module Magic Number: 20120211:27_x000D_
        Server loaded:  APR 1.5.1-dev, APR-UTIL 1.5.3_x000D_
        Compiled using: APR 1.5.1-dev, APR-UTIL 1.5.3_x000D_
        Architecture:   64-bit_x000D_
        Server MPM:     prefork_x000D_
          threaded:     no_x000D_
            forked:     yes (variable process count)_x000D_
        Server compiled with...._x000D_
         -D APR_HAS_SENDFILE_x000D_
         -D APR_HAS_MMAP_x000D_
         -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)_x000D_
         -D APR_USE_SYSVSEM_SERIALIZE_x000D_
         -D APR_USE_PTHREAD_SERIALIZE_x000D_
         -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT_x000D_
         -D APR_HAS_OTHER_CHILD_x000D_
         -D AP_HAVE_RELIABLE_PIPED_LOGS_x000D_
         -D DYNAMIC_MODULE_LIMIT=256_x000D_
         -D HTTPD_ROOT="/etc/apache2"_x000D_
         -D SUEXEC_BIN="/usr/lib/apache2/suexec"_x000D_
         -D DEFAULT_PIDLOG="/var/run/apache2.pid"_x000D_
         -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"_x000D_
         -D DEFAULT_ERRORLOG="logs/error_log"_x000D_
         -D AP_TYPES_CONFIG_FILE="mime.types"_x000D_
         -D SERVER_CONFIG_FILE="apache2.conf"
    _x000D_
    _x000D_
    _x000D_


For me this works on Debian 6 (Squeeze):

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

I had to go to the right path:

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

./apachectl: line 71: ulimit: open files: cannot modify limit: Operation not permitted
Server version: Apache/2.2.21 (Unix)
Server built: Dec 17 2011 19:57:53


Or, less directly:

nmap -A localhost -p 80


This works for my Debian:

$ /usr/sbin/apache2 -v

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

If it does not work for you, run the command with sudo.


Surely typing /usr/sbin/apache2 -v into the shell is the best and quickest way to go, by the way here's another option, just in case there's PHP too in your server and you're interested into gathering Apache version (and much more infos) in quick programmatical steps.

Just make an info.php file in your Apache web root folder (or whatever you like) and write these inside it:

<?php
    phpinfo();
?>

Now go to yoursite.com/info.php (or localhost/info.php for local machines).

You'll see your Apache version in PHP Variables section, here's an example:

phpinfo() example dump page

Also, please notice that these steps obviously apply to any web server with PHP integration, so it's not limited to Apache and once created that page could be handy while developing (just don't forget to remove it on production environments!!)


Some installations of Apache are fubar (think Oracle's packaging of it, OHS) and do not understand the -V flag, nor can be invoked directly without running into missing library errors.

Easiest way is to use the strings command (part of binutils) on the httpd binary and grep for a string that might resemble a version. For example, assuming your httpd binary is under directory /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

Most binaries (not all) contain their version (at least their major version) as static strings. This is my go-to way to get versions (or to corroborate what a binary's help message matches what reality on the ground truly is.)


You should use apache2ctl -v or apache2 -v for newer Debian or Ubuntu distributions.

apache:/etc/apache2# apache2ctl -v
Server version: Apache/2.2.16 (Debian)
Server built:   May 12 2011 11:58:18

or you can use apache2 -V to get more information.

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

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

If it does not work for you, run the command with sudo.


I think you have to be sure what type of installation you have binary or source. To check what binary packages is installed: with root rights execute following command:

dpkg -l |grep apache2

result should be something like:

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)

To find version you can run :

apache2ctl -V |grep -i "Server version"

result should be something like: Server version: Apache/2.4.10 (Debian)


The command varies depending on how your version of Linux has named the Apache Server.

On Debian and Mac OS:

apachectl -v

On Red Hat and Amazon's EC2 Linux use:

httpd -v

On other verisons of Linux try:

apache2 -v

You can use two different flags:

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

If you want to run the command with the full directory like user3786265 did but don't know where your apache is located, use the whereis command:

whereis httpd

Try it with 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....

Another way round to check a package (including Apache) installed version on Debian-based system, we can use:

apt-cache policy <package_name>

e.g. for Apache

apt-cache policy apache2

which will show something like (look at the Installed line):

$ 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

Try it with 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....

Some installations of Apache are fubar (think Oracle's packaging of it, OHS) and do not understand the -V flag, nor can be invoked directly without running into missing library errors.

Easiest way is to use the strings command (part of binutils) on the httpd binary and grep for a string that might resemble a version. For example, assuming your httpd binary is under directory /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

Most binaries (not all) contain their version (at least their major version) as static strings. This is my go-to way to get versions (or to corroborate what a binary's help message matches what reality on the ground truly is.)


You can also use the package manager directly:

dpkg -l | grep apache

This isn't focused on just version number, but it will make a broader search, which will give you other useful information, like module versions.


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

If it does not work for you, run the command with sudo.


Or, less directly:

nmap -A localhost -p 80


Surely typing /usr/sbin/apache2 -v into the shell is the best and quickest way to go, by the way here's another option, just in case there's PHP too in your server and you're interested into gathering Apache version (and much more infos) in quick programmatical steps.

Just make an info.php file in your Apache web root folder (or whatever you like) and write these inside it:

<?php
    phpinfo();
?>

Now go to yoursite.com/info.php (or localhost/info.php for local machines).

You'll see your Apache version in PHP Variables section, here's an example:

phpinfo() example dump page

Also, please notice that these steps obviously apply to any web server with PHP integration, so it's not limited to Apache and once created that page could be handy while developing (just don't forget to remove it on production environments!!)


This works for my Debian:

$ /usr/sbin/apache2 -v

For me this works on Debian 6 (Squeeze):

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

I had to go to the right path:

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

./apachectl: line 71: ulimit: open files: cannot modify limit: Operation not permitted
Server version: Apache/2.2.21 (Unix)
Server built: Dec 17 2011 19:57:53


Examples related to apache

Enable PHP Apache2 Switch php versions on commandline ubuntu 16.04 Laravel: PDOException: could not find driver How to deploy a React App on Apache web server Apache POI error loading XSSFWorkbook class How to enable directory listing in apache web server Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details How to enable php7 module in apache? java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient The program can't start because api-ms-win-crt-runtime-l1-1-0.dll is missing while starting Apache server on my computer

Examples related to debian

E: Unable to locate package npm How to update-alternatives to Python 3 without breaking apt? What is difference between arm64 and armhf? github: server certificate verification failed "Call to undefined function mysql_connect()" after upgrade to php-7 Debian 8 (Live-CD) what is the standard login and password? How to set the locale inside a Debian/Ubuntu Docker container? ps command doesn't work in docker container Forwarding port 80 to 8080 using NGINX Switching users inside Docker image to a non-root user

Examples related to version

Which TensorFlow and CUDA version combinations are compatible? How can the default node version be set using NVM? Node - was compiled against a different Node.js version using NODE_MODULE_VERSION 51 Which ChromeDriver version is compatible with which Chrome Browser version? How to find which version of TensorFlow is installed in my system? How to update Ruby Version 2.0.0 to the latest version in Mac OSX Yosemite? What does 'Unsupported major.minor version 52.0' mean, and how do I fix it? Find nginx version? How to check all versions of python installed on osx and centos How can I specify the required Node.js version in package.json?