It seems a simple apt-get remove apache2 does not completely remove apache2 as I can still see it on one of the processes when running top. How does one remove apache2 completely on his ubuntu server?
It's not removed indeed:
~# which apache2
/usr/sbin/apache2
~# whereis apache2
apache2: /usr/sbin/apache2 /etc/apache2 /usr/lib/apache2 /usr/share/apache2 /usr/share/man/man8/apache2.8.gzBut when I do apt-get remove apache2 again:
# apt-get remove apache2
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package apache2 is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 2 8 Answers
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 autoremoveIf 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).
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-commonFinally, run
sudo apt-get autoremovejust 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 linesudo service apache2 start- should returnapache2: unrecognized service
A very simple and straightforward way that worked for me is as follows:
Stop
apache2.sudo service apache2 stopUninstall Apache2 and its dependent packages.
sudo apt-get purge apache2 apache2-utils apache2.2-bin apache2-commonUse
autoremoveoption to get rid of other dependencies.sudo apt-get autoremoveCheck whether there are any configuration files that have not been removed.
whereis apache2If you get a response as follows
apache2: /etc/apache2remove 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
1Remove apache2 from the Ubuntu
To remove totally from your localhost
1st check the current status using
service apache2 statusif it's active (running)write next
sudo apt remove apache2*Say yes using y.
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 Take time to check if you are using the different package apache2.2-bin for Ubuntu 16.04 the latest is apache2.4-bin
sudo apt-get purge apache2 apache2-utils apache2.4-bin apache2.4-common
I tried the other answers here but this is the most complete solution I have found which worked for me:
$ sudo service apache2 stop
$ sudo apt-get purge apache2 apache2-utils apache2.2-bin apache2-common
$ sudo apt-get autoremoveThe output of the below command will provide you with information the installed package software, version, architecture and short description about the package. grep command is used to find the apache package
$ sudo dpkg --get-selections | grep apache | cut -f 1
$ sudo apt-get remove --purge <package name from the previous command output>
$ sudo whereis apache
$ sudo rm -rf <directory/file path from the previous command output>see
For a Debian based OS, like Ubuntu, use:
sudo apt remove --purge apache2
sudo apt autoremove -y