28

Is there a way to check if Apache is installed on my Ubuntu 14.04 (Trusty Tahr) machine?

I am trying to install LAMP on my Ubuntu installation.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Suraj
  • 2,423
  • 12
  • 39
  • 75

3 Answers3

57

You can use the below commands to check if Apache is installed or not:

dpkg --get-selections | grep apache

or

apache2 -v
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Manish R
  • 2,312
  • 17
  • 13
4

Command:

dpkg --get-selections | grep apache

Output:

apache2            install
apache2-bin        install
apache2-data       install
apache2-utils      install

Command:

apache2 -v

Output

Server version: Apache/2.4.18 (Ubuntu)
Server built:   2019-10-08T13:31:25
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Alankar
  • 55
  • 1
  • 2
  • When possible, please make an effort to provide additional explanation instead of just code. Such answers tend to be more useful as they help members of the community and especially new developers better understand the reasoning of the solution, and can help prevent the need to address follow-up questions. – Rajan May 12 '20 at 10:52
0

This might be useful for a more generic approach, not depending on dpkg

command -v apache2

There's a post on this subject: How can I check if a program exists from a Bash script?

Hugo Pinto
  • 11
  • 1