88

I know about the phpinfo() way but is there any other way? I'm using CentOS and I can't find the httpd executable to run httpd -v.

6 Answers 6

98

Either rpm -q httpd or /usr/sbin/httpd -v should work.

6
  • Thanks! I kept looking in /sbin instead of /usr/sbin but both of those worked! Hopefully Google will index this answer instead of the garbage that is out there.
    – tooshel
    Commented Feb 2, 2011 at 16:15
  • 1
    @tooshel: You could have tried locate. "locate bin/httpd". Assuming it's installed, not sure it's standard on CentOS. Commented Feb 2, 2011 at 16:39
  • Yeah, we do have locate . . . I found out because another colleague was convinced I didn't move something because the "locate" index was not updated. I still always forget it's there! Thanks!
    – tooshel
    Commented Feb 4, 2011 at 16:25
  • 1
    Can confirm this works on Mac OS El Capitan.
    – crmpicco
    Commented Jul 7, 2016 at 1:52
  • This does not work. It only figures out the apache version on the harddisk. Not the currently running one.
    – Peter
    Commented May 25, 2022 at 9:07
80

For recent Apache versions, try this:

$ /usr/sbin/apache2 -v

The output should be something like this:

Server version: Apache/2.4.7 (Ubuntu)
Server built:   Jul 24 2015 17:25:11
3
  • 1
    This worked on GNU/Linux 9 (stretch). Thanks !
    – navule
    Commented Dec 20, 2019 at 11:58
  • Works ™ for Ubuntu 18.04.4 LTS.
    – COil
    Commented Feb 23, 2020 at 7:49
  • I can confirm it works on Debian GNU/Linux 8.11 (jessie)
    – kanlukasz
    Commented Jul 27, 2020 at 10:16
8

Run this command in your console:

apache2 -v

Output should be something like:

Server version: Apache/2.4.7 (Ubuntu)
Server built:   Jan 14 2016 17:45:23
7

You can use:

sudo httpd -v

The result will look like this :

Server version: Apache/2.4.5 (CentOS)
Server built:   Aug  2 2019 10:41:15
1
  • Welcome to the site. Your answer seems rather similar to what @jsbillings proposed; would you mind to add some explanation on where your approach differs or what new aspect it tackles?
    – AdminBee
    Commented Feb 26, 2020 at 11:38
5

The above check only includes the primary version number, not including the extended backport patches.

If you installed with yum you can:

yum list httpd

and get the full version (note the -31 / -47)

Installed Packages httpd.x86_64 2.2.15-31.el6.centos Available Packages httpd.x86_64 2.2.15-47.el6.centos

1

for ports users:

port list apache2
apache2                        @2.4.28         www/apache2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .