In this guide, we’ll be going over the step by step instructions to remove Apache web server from Ubuntu Linux. Ubuntu offers us two options for uninstalling the software, either “remove” or “purge.” Read on to learn the difference and find out how to perform either function.
In this tutorial you will learn:
- How to remove, purge, or reinstall Apache web server from Ubuntu
|Category||Requirements, Conventions or Software Version Used|
|Other||Privileged access to your Linux system as root or via the
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of
$ – requires given linux commands to be executed as a regular non-privileged user
Remove, Purge, or Reinstall Apache Web Server
Remove will uninstall Apache from the system, but leave the configuration files behind. In particular, this means that site configuration files in the
/etc/apache2 directory are left alone. If you have any intention of reinstalling Apache in the future, you should use the remove option instead of purge. Of course, the website files themselves, stored inside
/var/www will also not be deleted during the removal process.
Open a terminal and type the following command to remove Apache web server.
$ sudo apt remove apache2
Purge will uninstall Apache from the system, along with the configuration files inside
/etc/apache2. That directory will be deleted entirely. If the
/var/www is not empty, then the removal process leaves it intact, so you don’t need to worry about purge deleting your entire website. If you don’t plan to reinstall Apache in the future, and don’t need your configuration files (or have already made a backup of them), then the purge option is for you. To err on the safe side, it’s advisable to backup your website files before doing a purge anyway.
Open a terminal and type the following command to purge Apache web server.
$ sudo apt purge apache2
Reinstall will remove Apache from your system and then install it again. It won’t make changes to your configuration files or
/var/www directory. Rather, Apache system files are deleted and replaced. Your installation of Apache would have to be pretty screwed up in order to justify this option, but it’s there in case you need it.
Open a terminal and type the following command to reinstall Apache web server.
$ sudo apt reinstall apache2
In this guide, we saw a couple different options for removing Apache web server from Ubuntu Linux. Ubuntu’s APT package manager makes uninstalling software very simple. The option to remove vs purge also protects users from accidentally deleting important files that they may want later (if, for example, they decide to reinstall Apache).
Keep in mind that other web hosting components may still be installed on your system. For example, PHP and MySQL. Those are separate packages, maintained outside of Apache, so you’ll need to remove them individually if you no longer want that software on your system.