CentOS7.6配置CentOS-7-x86_64-Everything-1810.iso本地镜像源

个人博客网站:www.zhaoq.top

 

1,准备工作

需要下载CentOS-7-x86_64-Everything-1810.iso镜像并放置到服务器上,

2,挂在镜像

# mount -o loop /opt/CentOS-7-x86_64-Everything-1810.iso /mnt

  mount :挂载命令,-o loop:指定将ISO文件以loop模式挂载,即将文件看作一个块设备  /mnt: 被挂载目的地,即挂载点。

3,创建本地yum源目录 

# mkdir /yum

4,将CentOS-7-x86_64-Everything-1810.iso挂载到本地yum源目录下

# mount -o loop /opt/CentOS-7-x86_64-Everything-1810.iso /yum

5,安装并启动HTTP服务

# yum -y install httpd

# systemctl start httpd && systemctl enable httpd

6,配置防火墙

  如果启动了防火墙,需要放行HTTP服务默认端口 80

# firewall-cmd --add-service=http --permanent

# firewall-cmd --reload

7,修改本地yum源文件----这一步可以省略,直接修改原yum源文件为好

  

# vi /etc/yum.repos.d/local.repo

[local]
name=local
baseurl=http://your-server-ip/yum
enabled=1
gpgcheck=0

  将your-server-ip替换为服务器ip就可以了

8,访问测试

http://your-server-ip/yum

 网页出现这样的画面代表成功了

9,外部的服务器能够使用该源

  备份原CentOS-Base.repo 

# cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak

  编辑CentOS-Base.repo

# vi CentOS-Base.repo
[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
baseurl=baseurl=http://your-server-ip/yum
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

  ******只保留 [base] 即可******

  ******删除 [updates] [extras] [centosplus]*****

  保存退出

10,清楚缓存

# yum clean all

11,检查配置是否生效

# yum list

  如果能看到软件包列表,表示配置生效

以上如有哪里配置有问题欢迎指正,本人也是尝试配置。

posted @ 2023-06-07 10:30  日光倾城-  阅读(1837)  评论(0)    收藏  举报