Linux – Removing Apache HTTP Server


To totally unlock this section you need to Log-in

Removing Apache HTTP Server ensures that, it’s existing files or services will not create conflict when we install Apache HTTP Server from the source code.

The following procedure will completely remove Apache HTTP Server, the httpd daemon, from our system.

  1. Removing Apache HTTP Server Packages.
  2. Removing Apache User and Group.
  3. Removing extra files.

Removing Apache HTTP Server Packages

Apache HTTP Server packages come in two variations. Packages starting with httpd in their name provides server components. While packages starting with mod_ in their name provides server modules.

Let us get a list of all installed packages with httpd in their name. In the terminal, execute the following command.

yum list installed *httpd*

The following there are the explanations of each option used in the command above:

  • list: is used to list various information about available packages; more complete details are available in the List Options section.
  • installed: list the packages installed on the system specified by args. If an argument does not match the name of an available package, it is assumed to be a shell-style glob and any matches are printed.

We will get a list of all installed packages having httpd in their name.

NOTE: Repository information has been stripped from the below output.

httpd.i686			2.2.15-15.el6.centos.1
httpd-devel.i686		2.2.15-15.el6.centos.1
httpd-manual.noarch		2.2.15-15.el6.centos.1
httpd-tools.i686		2.2.15-15.el6.centos.1

Now, let us get a list of all installed packages with mod_ in their name. In the terminal, execute the following command:

# yum list installed *mod_*

The following there are the explanations of each option used in the command above:

  • list: is used to list various information about available packages; more complete details are available in the List Options section.
  • installed: list the packages installed on the system specified by args. If an argument does not match the name of an available package, it is assumed to be a shell-style glob and any matches are printed.

We will get a list of all installed packages having mod_ in their name.

NOTE: Repository information has been stripped from the below output.

mod_auth_kerb.i686		5.4-9.el6
mod_auth_mysql.i686		1:3.0.0-11.el6_0.1
mod_auth_pgsql.i686		2.0.3-10.1.el6
mod_authz_ldap.i686		0.26-15.el6
mod_dav_svn.i686		1.6.11-7.el6
mod_dnssd.i686			0.6-2.el6
mod_nss.i686			1.0.8-15.el6
mod_perl.i686			2.0.4-10.el6
mod_revocator.i686		1.0.3-9.el6
mod_ssl.i686			1:2.2.15-15.el6.centos.1
mod_wsgi.i686			3.2-1.el6

We can get a description of each of the above package by using the yum info command. For example, to get information on httpd.i686 package, execute the following command. The architecture spec i686 need not be specified.

# yum info httpd
  • info: is used to list a description and summary information about available packages; takes the same arguments as in the List Options section.

Also we can get a list of all files with their locations, installed by a specific package, by using the rpm -ql command. For example, to get information on httpd.i686 package, execute the following command. The architecture spec i686 need not be specified.

# rpm -ql httpd

  • -q: query.
  • -l: list files in package.

The yum descriptions for each package is given below. It is for us to understand what each packages are, so that we can decide which of them to remove.

  • httpd.i686: the Apache HTTP Server is a powerful, efficient, and extensible web server.
  • httpd-devel.i686: the httpd-devel package contains the APXS binary and other files that you need to build Dynamic Shared Objects (DSOs) for the Apache HTTP Server. If you are installing the Apache HTTP server and you want to be able to compile or develop additional modules for Apache, you need to install this package.
  • httpd-manual.noarch: the httpd-manual package contains the complete manual and reference guide for the Apache HTTP server. The information can also be found at http://httpd.apache.org/docs/2.2/.
  • httpd-tools.i686: the httpd-tools package contains tools which can be used with the Apache HTTP Server.
  • mod_auth_kerb.i686: mod_auth_kerb is module for the Apache HTTP Server designed to provide Kerberos authentication over HTTP. The module supports the Negotiate authentication method, which performs full Kerberos authentication based on ticket exchanges.
  • mod_auth_mysql.i686: mod_auth_mysql can be used to limit access to documents served by a web server by checking data in a MySQL database.
  • mod_auth_pgsql.i686: mod_auth_pgsql can be used to authenticate remote users of the Apache HTTP Server based on queries against in a PostgresQL database.
  • mod_authz_ldap.i686: the mod_authz_ldap package provides support for authenticating users of the Apache HTTP server against an LDAP database. mod_authz_ldap features the ability to authenticate users based on the SSL client certificate presented, and also supports password aging, and authentication based on role or by configured filters.
  • mod_dav_svn.i686: the mod_dav_svn package allows access to a Subversion repository using HTTP, via the Apache httpd server.
  • mod_dnssd.i686: mod_dnssd is an Apache HTTPD module which adds Zeroconf support via DNS-SD using Avahi.
  • mod_nss.i686: the mod_nss module provides strong cryptography for the Apache Web server via the Secure Sockets Layer (SSL) and Transport Layer Security (TLS) protocols using the Network Security Services (NSS) security library.
  • mod_perl.i686: mod_perl incorporates a Perl interpreter into the Apache web server, so that the Apache web server can directly execute Perl code. Mod_perl links the Perl runtime library into the Apache web server and provides an object-oriented Perl interface for Apache's C language API. The end result is a quicker CGI script turnaround process, since no external Perl interpreter has to be started. Install mod_perl if you're installing the Apache web server and you'd like for it to directly incorporate a Perl interpreter.
  • mod_revocator.i686: The mod_revocator module retrieves and installs remote Certificate Revocate Lists (CRLs) into an Apache web server.
  • mod_ssl.i686: the mod_ssl module provides strong cryptography for the Apache Web server via the Secure Sockets Layer (SSL) and Transport Layer Security (TLS) protocols.
  • mod_wsgi.i686: the mod_wsgi adapter is an Apache module that provides a WSGI compliant interface for hosting Python based web applications within Apache. The adapter is written completely in C code against the Apache C runtime and for hosting WSGI applications within Apache has a lower overhead than using existing WSGI adapters for mod_python or CGI.

For removing Apache HTTP Server packages, we must remove all of the above packages. In the terminal, execute the following command:

# yum remove httpd httpd-devel httpd-manual httpd-tools mod_auth_kerb mod_auth_mysql mod_auth_pgsql mod_authz_ldap mod_dav_svn mod_dnssd mod_nss mod_perl mod_revocator mod_ssl mod_wsgi

  • remove: are used to remove the specified packages from the system as well as removing any packages which depend on the package being removed. remove operates on groups, files, provides and filelists just like the "install" command. We will get a detailed list of all packages along with their dependencies, ready to be removed. There will be also a [y/N] prompt, asking permission to continue.

Linux - Removing Apache HTTP Server

If we remove Apache HTTP Server packages, the dependency packages will also be removed. That is a loss we have to take. The yum descriptions for dependency packages are given below.

  • gnome-user-share.i686: gnome-user-share is a small package that binds together various free software projects to bring easy to use user-level file sharing to the masses. The program is meant to run in the background when the user is logged in, and when file sharing is enabled a webdav server is started that shares the $HOME/Public folder. The share is then published to all computers on the local network using mDNS/rendezvous, so that it shows up in the Network location in GNOME. The program also allows to share files using ObexFTP over Bluetooth.
  • ipa-server.i686: IPA is an integrated solution to provide centrally managed Identity (machine, user, virtual machines, groups, authentication credentials), Policy (configuration settings, access control information) and Audit (events, logs, analysis thereof). If you are installing an IPA server you need to install this package (in other words, most people should NOT install this package).
  • ipa-server-selinux.i686: IPA is an integrated solution to provide centrally managed Identity (machine, user, virtual machines, groups, authentication credentials), Policy (configuration settings, access control information) and Audit (events, logs, analysis thereof). This package provides SELinux rules for the daemons included in ipa-server.
  • mailman.i686: Mailman is software to help manage email discussion lists, much like Majordomo and Smartmail. Unlike most similar products, Mailman gives each mailing list a webpage, and allows users to subscribe, unsubscribe, etc. over the Web. Even the list manager can administer his or her list entirely from the Web. Mailman also integrates most things people want to do with mailing lists, including archiving, mail < -> news gateways, and so on. Documentation can be found in: /usr/share/doc/mailman-2.1.12. When the package has finished installing, you will need to perform some additional installation steps, these are described in: /usr/share/doc/mailman-2.1.12/INSTALL.REDHAT.
  • perl-Frontier-RPC.noarch: Frontier::RPC implements UserLand Software's XML RPC (Remote Procedure Calls using Extensible Markup Language). Frontier::RPC includes both a client module for making requests to a server and several server modules for implementing servers using CGI, Apache, and standalone with HTTP::Daemon.
  • webalizer.i686: the Webalizer is a Web server log analysis program. It is designed to scan Web server log files in various formats and produce usage statistics in HTML format for viewing through a browser. It produces professional looking graphs which make analyzing when and where your Web traffic is coming from easy.

Type y and press Enter to continue. All the Apache HTTP Server packages along with their dependencies will be removed from the system.

Removing Apache User and Group

Apache HTTP Server runs under the user and group, both named apache. The default home directory of user apache is /var/www/. It is provided by the package httpd.i686. Despite the package being removed, the directory is still there. Let us remove the user and group along with the home directory. In the terminal, execute the following command:

# userdel -r apache

  • -r: files in the user's home directory will be removed along with the home directory itself and the user's mail spool. Files located in other file systems will have to be searched for and deleted manually.

We will get the following error:

ERROR: userdel: /var/www not owned by apache, not removing

The user and group has been removed. Only thing remaining is the directory /var/www/. Let us remove it manually. In the terminal, execute the following command:

# rm -rfv /var/www

  • -r: remove directories and their contents recursively.
  • -f: ignore nonexistent files, never prompt.
  • -v: explain what is being done.

Removing extra files

We had removed the package httpd.i686. But the directories /etc/httpd/ and /usr/lib/httpd/ provided by it still exists. Let us remove them manually. In the terminal, execute the following commands:

# rm -rfv /etc/httpd
# rm -rfv /usr/lib/httpd

  • -r: remove directories and their contents recursively.
  • -f: ignore nonexistent files, never prompt.
  • -v: explain what is being done.

Removing Apache2 daemon

The first step is to stop any running instance of Apache2, because Apache2 will not be properly removed while it is running.

$ sudo service apache2 stop

Then uninstall Apache2 and its dependent packages. Use purge option instead of remove with apt-get command. The former option will try to remove dependent packages, as well as any configuration files created by them. In addition, use autoremove option as well, to remove any other dependencies that were installed with Apache2, but are no longer used by any other package.

$ sudo apt-get purge apache2 apache2-utils apache2.2-bin apache2-common
$ sudo apt-get autoremove

Finally, check if there is any configuration files or manual pages belonging to Apache2, which are still not removed.

$ whereis apache2
apache2: /etc/apache2

In this example, /etc/apache2 directory still exists. Since this directory (as well as any configuration files in it) is no longer necessary, go ahead and remove it manually.

$ sudo rm -rf /etc/apache2