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

CentOS7制作本地yum源(EPEL)步骤很多情况下机器上不了互联网 无法使用默认的 yum 源安装软件 因此搭建本地 yum 源非常有必要 准备工作配置网络等 创建 yum 源用到的目录 mkdir p data soft epel data soft centos7 配置本机 yum 源方法一 使用阿里源阿里源配置相对方便 具体帮助见 https developer aliyun com mirror 备份 CentOS Base repomv etc yum repos d CentOS Base repo etc yu

很多情况下机器上不了互联网,无法使用默认的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 
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/232422.html原文链接:https://javaforall.net

(0)
上一篇 2025年10月12日 下午2:01
下一篇 2025年10月12日 下午2:22


相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号