How to uninstall Apache2 on Ubuntu

0 votes
How do I uninstall Apache2 on ubuntu?
May 13, 2019 in Linux Administration by Laksha
39,845 views

3 answers to this question.

0 votes

Hey @Laksha, execute the following commands:

$ sudo service apache2 stop
$ sudo apt-get purge apache2 apache2-utils apache2.2-bin apache2-common
$ sudo apt-get autoremove
$ whereis apache2
apache2: /etc/apache2
$ sudo rm -rf /etc/apache2

answered May 13, 2019 by Hemant
0 votes

Follow these steps to remove the apache2 service using Terminal:

  1. First stop the apache2 service if it is running with: sudo service apache2 stop
  2. Now remove and clean up 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
    
  3. 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:

  1. which apache2 - should return a blank line
  2. sudo service apache2 start - should return apache2: unrecognized service
answered Dec 13, 2020 by Roshni
• 10,420 points
0 votes

apache2 is a meta package 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).

answered Dec 13, 2020 by Gitika
• 65,870 points

Related Questions In Linux Administration

+2 votes
1 answer

Not able to install npm on Ubuntu

Try installing npm using aptitude: sudo apt install aptitude sudo ...READ MORE

answered Nov 28, 2018 in Linux Administration by Omkar
• 69,090 points
4,765 views
0 votes
1 answer

Error when trying to install a few packages on ubuntu

Try executing the following commands and try ...READ MORE

answered Mar 15, 2019 in Linux Administration by Jobin
508 views
0 votes
1 answer

Ubuntu 10.10: Connecting to a terminal to a serial-to-USB device on Maverick Meerkat

Check with dmesg | grep tty if system recognize ...READ MORE

answered Jun 10, 2019 in Linux Administration by Upasana
• 8,620 points
1,760 views
0 votes
1 answer

How to find all files containing specific text on Linux?

Hi@akhtar, Linux systems have one interesting command name grep. ...READ MORE

answered Sep 22, 2020 in Linux Administration by MD
• 95,060 points
67 views
+1 vote
1 answer
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
946 views
0 votes
1 answer

Error saying " Invalid operation uninstall" on sudo apt uninstall apache2

Try this: sudo apt-get cpufrequtils is missing a mandatory ...READ MORE

answered May 13, 2019 in Linux Administration by Yesha
3,611 views
0 votes
2 answers

How to change IP address of an Ubuntu VM?

The easiest method is through network manager: 1- ...READ MORE

answered Aug 24, 2020 in Linux Administration by Pistle
• 300 points
2,009 views