Last updated on October 24, 2020 by Dan Nanni
It turns out that uninstalling Apache2 web server is not as straightforward as installing it. You will need to remove Apache2 package itself, as well as other dependent packages and its associated configurations. Here is how you remove Apache2 cleanly on Ubuntu and Debian.
The first step is to stop any running instance of Apache2, because Apache2 will not be properly removed while it is running.
$ sudo service apache2 stop
Then uninstall Apache2 and its dependent packages. Use purge
option instead of remove
option with apt-get
command. The former option will remove dependent packages, as well as any configuration files created by them. In addition, use autoremove
option as well, to remove any other dependencies that were installed with Apache2, but are no longer used by any other package.
$ sudo apt-get purge apache2 apache2-utils apache2.2-bin apache2-common $ sudo apt-get autoremove
Finally, check if there is any configuration files or manual pages belonging to Apache2, which are still not removed.
$ whereis apache2
apache2: /etc/apache2
In this example, /etc/apache2
directory still exists. Since this directory (as well as any configuration files in it) is no longer necessary, go ahead and remove it manually.
This website is made possible by minimal ads and your gracious donation via PayPal or credit card
Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.
Xmodulo © 2021 ‒ About ‒ Write for Us ‒ Feed ‒ Powered by DigitalOcean