CentOS7制作本地yum源(EPEL)步骤

很多情况下机器上不了互联网,无法使用默认的yum源安装软件,因此搭建本地yum源非常有必要。

准备工作

配置网络等。

创建yum源用到的目录。

mkdir -p /data/soft/epel    /data/soft/centos7

配置本机yum源

方法一:使用阿里源

阿里源配置相对方便。具体帮助见https://developer.aliyun.com/mirror/

# 备份CentOS-Base.repo
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
# 替换CentOS-Base.repo
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
# 替换epel-7.repo
curl -o /etc/yum.repos.d/epel-7.repo https://mirrors.aliyun.com/repo/epel-7.repo 
# 重建yum源缓存
yum clean all
yum makecache 

方法二:使用中科大源

具体帮助见https://mirrors.ustc.edu.cn/help/

# 替换CentOS-Base.repo
sudo sed -e 's|^mirrorlist=|#mirrorlist=|g' \
         -e 's|^#baseurl=http://mirror.centos.org/centos|baseurl=https://mirrors.ustc.edu.cn/centos|g' \
         -i.bak \
         /etc/yum.repos.d/CentOS-Base.repo
# 使CentOS-Base.repo生效
vi /etc/yum.repos.d/CentOS-Base.repo
enabled=1
# 重建yum源缓存
yum clean all
yum makecache
# 安装epel源
yum install -y epel-release
sudo sed -e 's|^metalink=|#metalink=|g' \
         -e 's|^#baseurl=https\?://download.fedoraproject.org/pub/epel/|baseurl=https://mirrors.ustc.edu.cn/epel/|g' \
         -e 's|^#baseurl=https\?://download.example/pub/epel/|baseurl=https://mirrors.ustc.edu.cn/epel/|g' \
         -i.bak \
         /etc/yum.repos.d/epel.repo
# 重建yum源缓存
yum makecache

安装yum仓库相关软件

yum install yum-utils createrepo -y

同步yum源

reposync -r epel -p /data/soft/epel

制作本地仓库

createrepo -v /data/soft/epel     
mount /dev/sr0 /mnt
cp -r /mnt/*  /data/soft/centos7/
createrepo -v /data/soft/centos7/ 

安装、配置vsftp在这里插入代码片

安装vsftp

yum install vsftpd -y

修改配置文件,设置匿名访问目录

vi /etc/vsftpd/vsftpd.conf
anon_root=/data/soft

设置vsftp服务

systemctl restart vsftpd
systemctl status vsftpd
systemctl enable vsftpd

设置selinux

vi /etc/selinux/config
将SELINUX设置为disabled
getenforce

设置防火墙,开放21端口

# 查询防火墙服务状态
systemctl status firewalld.service
# 查看所有端口列表
firewall-cmd --list-all
# 添加21端口
firewall-cmd --add-service=ftp --permanent
firewall-cmd --add-port=21/tcp --permanent
# 重新载入规则
firewall-cmd --reload
# 查看所有端口列表
firewall-cmd --list-all

使用本地yum源

# 移除所有yum源
mv /etc/yum.repos.d/*  /opt/
# 重建本地yum源
vi /etc/yum.repos.d/local.repo
[centos7]
name=centos
baseurl=ftp://192.168.100.202/centos7
gpgcheck=0
enabled=1
[epel]
name=epel
baseurl=ftp://192.168.100.202/epel
gpgcheck=0
enabled=1
  • 4
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值