CentOS / RHEL 5/6: Uninstall Apache (HTTPD) Server

by on May 4, 2013 · 0 comments· LAST UPDATED January 4, 2014

in , , ,

I do not want to use Apache server on a CentOS / RHEL 6 server. How do I uninstall and remove Apache (HTTPD) server using command line option on Red Hat Enterprise Linux / CentOS / Fedora Linux based server?

Tutorial details
DifficultyEasy (rss)
Root privilegesYes
RequirementsNone
Estimated completion time2m
You need to uninstall the following package on a CentOS / RHEL:

  1. httpd
  2. httpd-tools
  3. apr
  4. apr-util

Warning: Backup your Apache data stored in DocumentRoot (default /var/www/), configuration files in /etc/httpd/ and database if any.

Uninstall Apache on a CentOS / Red Hat Enterprise Linux (RHEL)

Login as a root user and type the following yum command:
$ sudo yum erase httpd httpd-tools apr apr-util
OR
# yum erase httpd httpd-tools apr apr-util
Sample outputs:

Loaded plugins: downloadonly, fastestmirror, security
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package apr.x86_64 0:1.3.9-5.el6_2 will be erased
---> Package apr-util.x86_64 0:1.3.9-3.el6_0.1 will be erased
--> Processing Dependency: apr-util = 1.3.9-3.el6_0.1 for package: apr-util-ldap-1.3.9-3.el6_0.1.x86_64
---> Package httpd.x86_64 0:2.2.15-29.el6.centos will be erased
---> Package httpd-tools.x86_64 0:2.2.15-29.el6.centos will be erased
--> Running transaction check
---> Package apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1 will be erased
--> Finished Dependency Resolution
 
Dependencies Resolved
 
================================================================================
 Package             Arch         Version                     Repository   Size
================================================================================
Removing:
 apr                 x86_64       1.3.9-5.el6_2               @base       296 k
 apr-util            x86_64       1.3.9-3.el6_0.1             @base       198 k
 httpd               x86_64       2.2.15-29.el6.centos        @base       2.9 M
 httpd-tools         x86_64       2.2.15-29.el6.centos        @base       137 k
Removing for dependencies:
 apr-util-ldap       x86_64       1.3.9-3.el6_0.1             @base       9.3 k
 
Transaction Summary
================================================================================
Remove        5 Package(s)
 
Installed size: 3.6 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Erasing    : httpd-2.2.15-29.el6.centos.x86_64                            1/5
  Erasing    : httpd-tools-2.2.15-29.el6.centos.x86_64                      2/5
  Erasing    : apr-util-ldap-1.3.9-3.el6_0.1.x86_64                         3/5
  Erasing    : apr-util-1.3.9-3.el6_0.1.x86_64                              4/5
  Erasing    : apr-1.3.9-5.el6_2.x86_64                                     5/5
  Verifying  : httpd-2.2.15-29.el6.centos.x86_64                            1/5
  Verifying  : apr-util-ldap-1.3.9-3.el6_0.1.x86_64                         2/5
  Verifying  : httpd-tools-2.2.15-29.el6.centos.x86_64                      3/5
  Verifying  : apr-util-1.3.9-3.el6_0.1.x86_64                              4/5
  Verifying  : apr-1.3.9-5.el6_2.x86_64                                     5/5
 
Removed:
  apr.x86_64 0:1.3.9-5.el6_2          apr-util.x86_64 0:1.3.9-3.el6_0.1
  httpd.x86_64 0:2.2.15-29.el6.centos httpd-tools.x86_64 0:2.2.15-29.el6.centos
 
Dependency Removed:
  apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1
 
Complete!
 

Update you firewall config

You need to edit /etc/sysconfig/iptables and remove line that allows TCP port 80/443 for Apache:
# vi /etc/sysconfig/iptables
Find and remove line as follows:

## open port 80 /443 ##
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT

Save and close the file. Restart iptables:
# service iptables restart
You need to repeat the same steps for ip6tables - IPv6 packet filter by editing /etc/sysconfig/ip6tables
# vi /etc/sysconfig/ip6tables
Find and remove line as follows:

## open port 80 /443 for IPv6 ##
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT

Save and close the file. Restart the ip6tables service:
# service ip6tables restart

Related media

This tutorial is also available in a quick video format:



(Video 01: Uninstall Apache Server on a CentOS / Red Hat Enterprise Linux)

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 0 comments… add one now }

Leave a Comment

Tagged as: , , , ,

Previous Faq:

Next Faq: