Centos7部署Apache做本地yum源

先看一下效果

[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

主要就是挂载光盘然后把光盘中的内容都cprepo

[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
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值