Check if Apache is installed on a Ubuntu machine Check if Apache is installed on a Ubuntu machine apache apache

Check if Apache is installed on a Ubuntu machine


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

dpkg --get-selections | grep apache

or

apache2 -v


Command:

dpkg --get-selections | grep apache

Output:

apache2            installapache2-bin        installapache2-data       installapache2-utils      install

Command:

apache2 -v

Output

Server version: Apache/2.4.18 (Ubuntu)Server built:   2019-10-08T13:31:25


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?