If you have previously installed Apache2 on Debian, and want to remove or uninstall it you can follow this article’s guidelines to learn different ways to do it.
Uninstall and Remove Apache2 on Debian
There are different ways to uninstall or remove Apache2 from Debian, which are as follows:
- from apt purge Command
- from apt remove Command
- from apt autoremove Command
- Remove Source Directories
Method 1: Remove Apache2 Using apt purge Command
To remove Apache2 from Debian, you can use the apt purge command that removes Apache2 and associated dependencies from the system.
Method 2: Remove Apache2 Using apt remove Command
You can also remove Apache2 from Debian using the apt remove command. The command works similar to the above command as it removes Apache2 and its associated dependencies from the system.
Method 3: Remove Apache2 Using autoremove Command
If you want to completely remove Apache2 from the Debian with configuration settings, you can use the following apt autoremove command:
Method 4: Remove Apache2 by Deleting Source Directories
You can also remove Apache2 from Debian by deleting its source directories. You can find the Apache2 source directories location using the following command:
Then remove those directories using the following command:
Note: There could be multiple directories, but the syntax to remove those directories remains the same.
Finally, to verify that everything is done as expected run the below-written command, and in the output, you should see no files, and this will confirm that Apache2 is uninstalled or removed completely from the system:
Conclusion
To uninstall or remove the Apache2 on Debian, the user can use the apt purge, apt remove, and apt autoremove commands. The users can also delete source directories to remove Apache2 from Debian. However, before that, the user must need to find the Apache2 source directories using the “whereis apache2” command. Then to remove the directories the “rm -r” command is used.