Permanently removing apache2
Solution 1:
apache2
is a metapackage that just selects other packages. If you installed apache by installing that package, you just need to run this to clean up the automatically selected packages:
sudo apt autoremove
If that doesn't work, you might have installed one of the dependents manually. You can target all the apache2-
packages from space and nuke the lot:
sudo apt remove apache2.*
For future reference, to find out which package a binary is from, you can run this:
dpkg -S `which apache2`
I'd expect that to come back with apache2.2-bin
(at the time of writing).
Solution 2:
Follow these steps to remove the apache2
service using Terminal
:
- First stop the apache2 service if it is running with:
sudo service apache2 stop
-
Now remove and cleanup all the apache2 packages with:
sudo apt-get purge apache2 apache2-utils apache2.2-bin apache2-common //or sudo apt-get purge apache2 apache2-utils apache2-bin apache2.2-common
Finally, run
sudo apt-get autoremove
just in case any other cleanup in needed
You can do the following two tests to confirm apache has been removed:
-
which apache2
- should return a blank line -
sudo service apache2 start
- should returnapache2: unrecognized service
Solution 3:
A very simple and straightforward way that worked for me is as follows:
-
Stop
apache2
.sudo service apache2 stop
-
Uninstall Apache2 and its dependent packages.
sudo apt-get purge apache2 apache2-utils apache2.2-bin apache2-common
-
Use
autoremove
option to get rid of other dependencies.sudo apt-get autoremove
-
Check whether there are any configuration files that have not been removed.
whereis apache2
-
If you get a response as follows
apache2: /etc/apache2
remove the directory and existing configuration files.sudo rm -rf /etc/apache2
Source: How to uninstall and remove Apache2 on Ubuntu or Debian by Dan Nanni
Solution 4:
First check if you are using right package name, IMO correct package name is : apache2.x-common
If you want to completely remove the package including config files then try:
dpkg --purge apache2.2-common