CentOS/RHEL 5/6:卸载Apache(HTTPD)服务器

时间:2020-01-09 10:43:56  来源:igfitidea点击:

我不想在CentOS/RHEL 6服务器上使用Apache服务器。
如何在基于Red Hat Enterprise Linux/CentOS/Fedora Linux的服务器上使用命令行选项卸载和删除Apache(HTTPD)服务器?

您需要在CentOS/RHEL上卸载以下软件包:

  • httpd
  • httpd工具
  • 4月
  • 实用程序

警告:备份存储在DocumentRoot中的Apache数据(默认为/var/www /),/etc/httpd /中的配置文件以及数据库(如果有)。

在CentOS/Red Hat Enterprise Linux(RHEL)上卸载Apache

以root用户身份登录,然后执行以下yum命令:

$ sudo yum erase httpd httpd-tools apr apr-util

或者

# yum erase httpd httpd-tools apr apr-util

输出示例:

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!

更新您的防火墙配置

您需要编辑/etc/sysconfig/iptables并删除允许Apache使用TCP端口80/443的行:

# vi /etc/sysconfig/iptables

查找并删除行,如下所示:

## 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

保存并关闭文件。
重启iptables:

# service iptables restart

您需要通过编辑/etc/sysconfig/ip6tables对ip6tables IPv6数据包过滤器重复相同的步骤。

# vi /etc/sysconfig/ip6tables

查找并删除行,如下所示:

## 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

保存并关闭文件。
重新启动ip6tables服务:

# service ip6tables restart