先看一下效果
[root@racbj01 ~]# curl 10.107.173.242
当前测试页面为专网服务器:10.107.173.242
++++++++++++++++++++++++++++++++++++++++++++++
执行如下命令挂载CentOS7.5的yum仓库
bash <(curl http://10.107.173.242/7.5/mount.sh)
++++++++++++++++++++++++++++++++++++++++++++++
执行如下命令挂载CentOS6.8的yum仓库
bash <(curl http://10.107.173.242/7.5/soft/6.8/mount.sh)
[root@racbj01 ~]# bash <(curl http://10.107.173.242/7.5/soft/6.8/mount.sh)
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
111 447 111 447 0 0 110k 0 --:--:-- --:--:-- --:--:-- 436k
mv: cannot stat `/etc/yum.repos.d/Cen*': No such file or directory
--2021-03-12 10:44:48-- http://10.107.173.242/7.5/soft/6.8/CentOS6.8.repo
Connecting to 10.107.173.242:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 89 [application/x-troff-man]
Saving to: “/etc/yum.repos.d/CentOS6.8.repo”
100%[=======================================================================================>] 89 --.-K/s in 0s
2021-03-12 10:44:48 (15.8 MB/s) - “/etc/yum.repos.d/CentOS6.8.repo” saved [89/89]
Loaded plugins: fastestmirror, refresh-packagekit, security
Cleaning repos: Local base
Cleaning up Everything
Cleaning up list of fastest mirrors
Loaded plugins: fastestmirror, refresh-packagekit, security
Determining fastest mirrors
Local | 4.0 kB 00:00
Local/primary_db | 4.7 MB 00:00
base | 4.0 kB 00:00 ...
base/primary_db | 4.7 MB 00:00 ...
repo id repo name status
Local Local 6,696
base base 6,696
repolist: 13,392
yum已经配置成功
[root@racbj01 ~]#
http
服务器
[root@yunwei repo]# rpm -q httpd
httpd-2.4.6-80.el7.centos.x86_64
[root@yunwei html]# pwd
/var/www/html
[root@yunwei html]# ll
total 4
drwxr-xr-x. 4 root root 68 Mar 12 10:35 7.5
-rw-r--r--. 1 root root 346 Mar 12 10:25 index.html
[root@yunwei html]# cat index.html
当前测试页面为专网服务器:10.107.173.242
++++++++++++++++++++++++++++++++++++++++++++++
执行如下命令挂载CentOS7.5的yum仓库
bash <(curl http://10.107.173.242/7.5/mount.sh)
++++++++++++++++++++++++++++++++++++++++++++++
执行如下命令挂载CentOS6.8的yum仓库
bash <(curl http://10.107.173.242/7.5/soft/6.8/mount.sh)
[root@yunwei 7.5]# pwd
/var/www/html/7.5
[root@yunwei 7.5]# ls
CentOS7.5.repo mount.sh repo soft##这个目录没啥用
[root@yunwei 7.5]# cat CentOS7.5.repo
[Local]
name=Local
baseurl=http://10.107.173.242/7.5/repo
enabled=1
gpgcheck=0
[root@yunwei 7.5]# cat mount.sh
#!/bin/bash
Cobak_fun(){
mv /etc/yum.repos.d/Cen* /etc/yum.repos.d/bak
wget -P /etc/yum.repos.d/ http://10.107.173.242/7.5/CentOS7.5.repo
yum clean all
yum repolist
echo "yum已经配置成功"
}
if [ -f /etc/yum.repos.d/CentOS7.5.repo ];then
echo "yum已经配置成功"
else
if [ -d /etc/yum.repos.d/bak ];then
Cobak_fun
else
mkdir /etc/yum.repos.d/bak
Cobak_fun
fi
fi
主要就是挂载光盘然后把光盘中的内容都cp
到repo
中
[root@yunwei 7.5]# ll
total 12
-rw-r--r--. 1 root root 80 Apr 23 2020 CentOS7.5.repo
-rw-r--r--. 1 root root 438 May 18 2020 mount.sh
drwxr-xr-x. 8 root root 4096 Nov 30 2019 repo
drwxr-x--x. 3 root root 78 Mar 12 10:23 soft
[root@yunwei 7.5]# pwd
/var/www/html/7.5
同理可以在/var/www/html
下建一个6.8目录
共享6.8
的光盘,这里因为/var/www/html/7.5/soft
有空间,所以就在/var/www/html/7.5/soft
下建立的6.8
,注意这里的6.8目录
要加执行权限
chmod +x /var/www/html/7.5/soft/6.8