Apache HTTP Server (also known as Apache) is a free and open-source web server that delivers web content through the internet. Being open source has made Apache very popular with developers and it is most popular webserver in this world. In this tutorial, you will learn How to Permanently Remove , Uninstall Apache2 from Ubuntu.

Uninstall / Remove apache2 from ubuntu

Stop your Apache server. Use the following command to stop apache2.

sudo service apache2 stop

Step 1:- Now remove apache2 packages using the following command

sudo apt-get remove apache2

Step 2:- Remove all config files of apache2

sudo apt-get purge apache2

Step 3:- Now use autoremove option to get rid of other dependencies.

sudo apt-get autoremove

Step 4:- Check whether there are any configuration files that have not been removed. Use the following command in the terminal to Check

whereis apache2

Output:-Permanently Remove/Uninstall Apache2

If you get a response as follows apache2: /etc/apache2 remove the directory and existing configuration files.

Generally, it is stored in etc directory but it can be in more than one directory (like above case). To remove the configuration file use the following command

sudo rm -rf /configuration_file_location

Ensure to replace configuration_file_location to your file name (got in whereis apache2)

Example:-

sudo rm -rf /etc/apache2

remove apache2 permanently

Tests to confirm apache web server has been removed or not

Now, it’s time to test the apache web server has been removed or not. Use the following command in terminal

Step 5:-

which apache2

Output: It should return a blank line.

But I am getting /usr/sbin/apache2 It means apache2 configuration file not removed completely. Permanently Remove/Uninstall Apache2

Note:- If which apache2 return any output except the blank line. It means apache2 configuration file not removed completely. Remove that configuration file also using command sudo rm -rf /configuration_file_location.

I am using here sudo rm -rf /usr/sbin/apache2 to remove the file Because I got /usr/sbin/apache2 as output using  which apache2. Ensure to replace /usr/sbin/apache2 to output you got using which apache2.

Uninstall Apache2 from Ubuntu

Conclusion

With the help of above tutorial. I hope, you will able to Permanently Remove/Uninstall Apache2 from Ubuntu.

Sharing is Caring

Comments are closed.

Scroll to Top