How can I check if Apache is installed in my Amazon Linux AMI, which is based on RHEL 6? In Ubuntu, I use:

dpkg --get-selections | grep apache

But that doesn't work in this case. Note, I need to be able to tell if Apache is installed even if it isn't a service.

  • Maybe you could try using the locate command? If the locate service is properly set up, try doing a locate apache. Another option is to use find, such as: find /usr -name 'apache*'.
    – thiagowfx
    Oct 4 '15 at 6:01
  • If Linux AMI is Red Had based distro, then it uses rpm packages (not deb). The tool to manage rpm package is not dpkg but rpm. You may find if apache was installed using package by issuing a command like: rpm -qa | grep -i apache
    – herbert
    Oct 4 '15 at 8:06

Two options that spring to my mind:

yum info httpd

check the output to see if it is installed or not, you get something like:

[0 1003 12:18:33] ~ % yum info httpd
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: ftp.halifax.rwth-aachen.de
 * extras: ftp.rrzn.uni-hannover.de
 * remi: mirror5.layerjet.com
 * remi-php56: mirror5.layerjet.com
 * remi-safe: mirror5.layerjet.com
 * updates: ftp.halifax.rwth-aachen.de
Installed Packages
Name        : httpd
Arch        : x86_64
Version     : 2.2.15
Release     : 47.el6.centos
Size        : 2.9 M
Repo        : installed
From repo   : updates
Summary     : Apache HTTP Server
URL         : http://httpd.apache.org/
License     : ASL 2.0
Description : The Apache HTTP Server is a powerful, efficient, and extensible
            : web server.

or do

rpm -qf /etc/httpd

to see if any package thinks it's responsible for httpd's config directory – on CentOS6, you get

[0 1001 12:12:46] ~ % rpm -qf /etc/httpd

(and easiest last, convention on RH/CentOS is that the config lives in /etc/httpd/, so its mere presence might be a bit of an indicator.)


The simplest approach is to invoke httpd, say by checking the version:

httpd -V

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.