Red Hat Enterprise Linux 7 配置本地yum源——之新手上路

由于Red Hat Enterprise Linux 7 的更新包只对注册的用户生效,所以需要自己手动更改成CentOS 的更新包,CentOS几乎和RedHat是一样的,所以无需担心软件包是否可安装,下面是安装步骤。

查看RHEL是否安装了yum,若是安装了,那么又有哪些yum包:

[[email protected] ~]# rpm -qa |grep yum

删除redhat自带的yum包

卸载上面显示的所有yum包:

[[email protected] ~]# rpm -qa|grep yum|xargs rpm -e --nodeps(不检查依赖,直接删除rpm包)

[[email protected] ~]# rpm -qa |grep yum (再次查看)

[[email protected] ~]# (无信息显示表示已经卸载完成。)

 

1、挂载DVD光盘到/mnt   因为配置时候路径名里面不能有空格,否则不能识别  

[[email protected] mnt]# mount /dev/cdrom /mnt  

2、在目录/etc/yum.repos.d/创建文件文件名.repo 

3、配置本地yum源

cd /etc/yum.repos.d/   #进入yum配置目录 

touch  rhel7.repo   #建立yum配置文件 

vim  rhel7.repo   #编辑配置文件,添加以下内容 

[rhel-yum]

name=rhel7                     #自定义名称 

baseurl=file:///mnt         #本地光盘挂载路径 

enabled=1                       #启用yum源,0为不启用,1为启用 

gpgcheck=0                     #检查GPG-KEY,0为不检查,1为检查 

:wq!                                    #保存退出 

4、、测试使用yum命令自动安装软件

yum clean all              #清除yum缓存 

yum makecache         #缓存本地yum源中的软件包信息

yum install httpd   #安装apache 

rpm -ql httpd  #查询所有安装httpd的目录和文件 

systemctl start httpd.service  #启动apache 

systemctl stop httpd.service  #停止apache 

systemctl restart httpd.service  #重启apache 

systemctl enable httpd.service  #设置开机启动 

RHEL 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙。

5、通过yum安装GUI图形界面# yum -y groupinstall "Server with GUI"可以执行startx看下效果。

      通过yum卸载软件 yum -y remove httpd(移除httpd软件)