Open the terminal and type:
apache2 -v
-v Print the version of apache2, and then exit.
Open the terminal and type:
apache2 -v
-v Print the version of apache2, and then exit.
From the terminal you can enter: (lowercase -v)
apachectl -v
or to get even more compile info on Apache enter: (uppercase -V)
apachectl -V
of course as mention by @karel you can also use apache2 instead of apachectl... just giving an alternative. This worked for me in Ubuntu 18.04 and I'm using Apache 2.4.37.
Videos
Why should I check my Apache version?
It is crucial to keep Apache updated to maintain security and ensure it is running optimally.
What is the easiest way to check Apache version?
Checking the Apache version through WHM is the easiest method for those who are not familiar with CLI. Simply navigate to Server Status > Apache Status, and you will have access to the current installed version of Apache.
How often should I check my Apache version?
It is a good practice to check Apache version regularly or when you suspect any security vulnerabilities. It is also recommended to keep your software up to date for optimal security and reliability.
You first need to find out where are those binaries stored. For this you may use the whereis command.
whereis httpd
The output will give you the different path for the files httpd like this:
httpd: /usr/sbin/httpd /usr/lib64/httpd /etc/httpd /usr/share/httpd /usr/share/man/man8/httpd.8.gz
Then, for the binaries, you can check the version using the path with the attribute -v
/usr/sbin/httpd -v
Output:
Server version: Apache/2.4.6 (CentOS)
Server built: Oct 19 2017 20:39:16
For the yum installed version, you may also use the following command:
sudo yum list installed httpd
Installed Packages
httpd.x86_64 2.4.6-67.el7.centos.6
Another last solution is to use: rpm -q httpd
You can check Apache Version in Ubuntu by using this Command -
apachectl -v
The Result will be like this -
vishal@vishal:~$ apachectl -v
Server version: Apache/2.4.41 (Ubuntu)
Server built: 2020-08-12T19:46:17
The method
Connect to port 80 on the host and send it
HEAD / HTTP/1.0
This needs to be followed by carriage-return + line-feed twice
You'll get back something like this
HTTP/1.1 200 OK
Date: Fri, 03 Oct 2008 12:39:43 GMT
Server: Apache/2.2.9 (Ubuntu) DAV/2 SVN/1.5.0 PHP/5.2.6-1ubuntu4 with Suhosin-Patch mod_perl/2.0.4 Perl/v5.10.0
Last-Modified: Thu, 02 Aug 2007 20:50:09 GMT
ETag: "438118-197-436bd96872240"
Accept-Ranges: bytes
Content-Length: 407
Connection: close
Content-Type: text/html; charset=UTF-8
You can then extract the apache version from the Server: header
Typical tools you can use
You could use the HEAD utility which comes with a full install of Perl's LWP library, e.g.
HEAD http://your.webserver.com/
Or, use the curl utility, e.g.
curl --head http://your.webserver.com/
You could also use a browser extension which lets you view server headers, such as Live HTTP Headers or Firebug for Firefox, or Fiddler for IE
Stuck with Windows?
Finally. if you're on Windows, and have nothing else at your disposal, open a command prompt (Start Menu->Run, type "cmd" and press return), and then type this
telnet your.webserver.com 80
Then type (carefully, your characters won't be echoed back)
HEAD / HTTP/1.0
Press return twice and you'll see the server headers.
Other methods
As mentioned by cfeduke and Veynom, the server may be set to return limited information in the Server: header. Try and upload a PHP script to your host with this in it
<?php phpinfo() ?>
Request the page with a web browser and you should see the Apache version reported there.
You could also try and use PHPShell to have a poke around, try a command like
/usr/sbin/apache2 -V
httpd -v will give you the version of Apache running on your server (if you have SSH/shell access).
The output should be something like this:
Server version: Apache/2.2.3
Server built: Oct 20 2011 17:00:12
As has been suggested you can also do apachectl -v which will give you the same output, but will be supported by more flavours of Linux.
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.
This works for my Debian:
$ /usr/sbin/apache2 -v
Installed: (none) means that there is no Apache installed on your server. You can install it with the following command:
sudo apt install apache2
In your case the first thing, you have to make sure that apache is install or not so
Run which apache2 to find the location of Apache. If it gives no output, then you don't have apache2 installed.
or you can check in
sudo /etc/init.d/apache2 start
You can also check using this command:
apt list --installed |grep apache2
if none of them works then you have to install apache or tell us what makes you think that apache is installed in your system