4

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.

Rui F Ribeiro
  • 55,929
  • 26
  • 146
  • 227
Rick Helston
  • 141
  • 1
  • 1
  • 4
  • 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 04 '15 at 06: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 04 '15 at 08:06

2 Answers2

6

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
httpd-2.2.15-47.el6.centos.x86_64

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

Ulrich Schwarz
  • 15,669
  • 4
  • 47
  • 58
3

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

httpd -V
jeffmcneill
  • 261
  • 3
  • 10