How to Uninstall Apache2 in Ubuntu

uninstall apache2 ubuntu

We can uninstall apache2 in Ubuntu using the apt-get purge command. But first, run the dpkg -l | grep -i apache2 command to check if apache is installed on your Ubuntu server.

check if apache is installed on your Ubuntu server

To uninstall apache2, run the following command:

apt-get purge apache2*

After that, run the apt-get autoremove command to remove all unnecessary packages which were initially installed on Ubuntu to satisfy dependencies for the apache2 web server.

apt-get autoremove

If you want to reinstall the Apache web server, run the apt install apache2 command.