For system, network and cloud administrators

How to uninstall Apache2 on Linux

Ubuntu server 18.04 LTS

  1. Check the Apache2 process status
sudo /etc/init.d/apache2 status 

If you’re seeing an Active (running) message then it means that your Apache2 process is still running and we need to stop it.

How to uninstall Apache2 on Linux – checking the Apache2 status on Ubuntu 18.04.3 LTS
  1. Stop the Apache2 process
sudo /etc/init.d/apache2 stop
How to uninstall Apache2 on Linux – stopping the Apache2 service on Ubuntu 18.04.3 LTS
  1. Check the Apache2 process status, again.
sudo /etc/init.d/apache2 status
How to uninstall Apache2 on Linux – checking status after stopping the Apache2 process on Ubuntu 18.04.3 LTS

Notice that now, the “Active” section says inactive.

  1. Uninstall Apache2 by purging.
sudo apt-get purge apache2* -y
How to uninstall Apache2 on Linux – purging Apache2 on Ubuntu 18.04.3 LTS
  1. Verify if anything related to the Apache2 service has been removed
 sudo apt-get autoremove -y
How to uninstall Apache2 on Linux – autoremove any leftovers after purging on Ubuntu 18.04.3 LTS
  1. Verify if any file or folders have been left on the server.
whereis apache2
How to uninstall Apache2 on Linux – whereis Apache2 on Ubuntu 18.04.3 LTS

If the result/output of the command above is empty, then Apache2 has been successfully uninstalled from your Ubuntu 18.04 LTS.


How to install LAMP (Linux, Apache, MySQL, PHP) web server

We sometimes find ourserlves in the position where we need to install a LAMP (Linux, Apache, MySQL, PHP) web server.