当前位置 博文首页 > 文章内容

    linux配置本地yum源与本地html yum源

    作者: 栏目:未分类 时间:2020-08-06 9:00:41

    本站于2023年9月4日。收到“大连君*****咨询有限公司”通知
    说我们IIS7站长博客,有一篇博文用了他们的图片。
    要求我们给他们一张图片6000元。要不然法院告我们

    为避免不必要的麻烦,IIS7站长博客,全站内容图片下架、并积极应诉
    博文内容全部不再显示,请需要相关资讯的站长朋友到必应搜索。谢谢!

    另祝:版权碰瓷诈骗团伙,早日弃暗投明。

    相关新闻:借版权之名、行诈骗之实,周某因犯诈骗罪被判处有期徒刑十一年六个月

    叹!百花齐放的时代,渐行渐远!



    在实际生产环境中,好多都是内网环境,因此不能使用网上的yum源进行软件的安装,好多依赖环境的安装又很复杂,所以就设置一下本地yum源,如果本地有多台服务器,也可以设置一下http用来提供yum源
    单台服务器设置本地yum源:
    将iso包上传到服务器

    [root@linux3 sga]# ll
    -rw-r--r--. 1 root root 4664066048 5月 29 09:28 CentOS-7-x86_64-DVD-1908.iso

    将iso包挂载到系统目录

    [root@linux3 sga]# mount -o loop CentOS-7-x86_64-DVD-1908.iso /mnt/cdrom/
    mount: /dev/loop0 写保护,将以只读方式挂载
    [root@linux3 sga]# ll /mnt/cdrom/
    总用量 694
    -rw-rw-r-- 1 root root 14 9月 10 2019 CentOS_BuildTag
    drwxr-xr-x 3 root root 2048 9月 6 2019 EFI
    -rw-rw-r-- 1 root root 227 8月 30 2017 EULA
    -rw-rw-r-- 1 root root 18009 12月 10 2015 GPL
    drwxr-xr-x 3 root root 2048 9月 10 2019 images
    drwxr-xr-x 2 root root 2048 9月 10 2019 isolinux
    drwxr-xr-x 2 root root 2048 9月 6 2019 LiveOS
    drwxrwxr-x 2 root root 671744 9月 12 2019 Packages
    drwxrwxr-x 2 root root 4096 9月 12 2019 repodata
    -rw-rw-r-- 1 root root 1690 12月 10 2015 RPM-GPG-KEY-CentOS-7
    -rw-rw-r-- 1 root root 1690 12月 10 2015 RPM-GPG-KEY-CentOS-Testing-7
    -r--r--r-- 1 root root 2883 9月 12 2019 TRANS.TB

    配置yum
    将/etc/yum.repos.d/目录下的原有的repo文件全部删除


    [root@linux3 yum.repos.d]# ll
    总用量 4
    -rw-r--r-- 1 root root 77 7月 17 08:57 cdrom.repo
    drwxr-xr-x. 2 root root 237 12月 30 2019 repo
    [root@linux3 sga]# cat /etc/yum.repos.d/cdrom.repo
    [cdrom]
    name=cdrom
    baseurl=file:///mnt/cdrom
    gpgcheck=0
    enabled=1

    单台服务器yum配置完成
    多台服务器设置html yum源
    前两步相同
    将iso包上传到服务器
    将iso包挂载到系统目录
    将挂载包复制到目录
    在/var/www/html目录下新建一个centos7目录,用来存放iso包的内容

    [root@linux3 html]# ll
    总用量 0
    drwxr-xr-x 8 root root 220 6月 1 16:02 centos7
    [root@linux3 html]# pwd
    /var/www/html
    [root@linux3 html]# cd centos7/
    [root@linux3 html]# cp -r /mnt/cdrom/* /var/www/html/centos7
    [root@linux3 centos7]# ll
    总用量 328
    -rw-r--r-- 1 root root 14 6月 1 16:01 CentOS_BuildTag
    drwxr-xr-x 3 root root 35 6月 1 16:01 EFI
    -rw-r--r-- 1 root root 227 6月 1 16:01 EULA
    -rw-r--r-- 1 root root 18009 6月 1 16:01 GPL
    drwxr-xr-x 3 root root 57 6月 1 16:01 images
    drwxr-xr-x 2 root root 198 6月 1 16:01 isolinux
    drwxr-xr-x 2 root root 43 6月 1 16:01 LiveOS
    drwxr-xr-x 2 root root 225280 6月 1 16:02 Packages
    drwxr-xr-x 2 root root 4096 6月 1 16:02 repodata
    -rw-r--r-- 1 root root 1690 6月 1 16:02 RPM-GPG-KEY-CentOS-7
    -rw-r--r-- 1 root root 1690 6月 1 16:02 RPM-GPG-KEY-CentOS-Testing-7
    -r--r--r-- 1 root root 2883 6月 1 16:02 TRANS.TBL

    启动httpd服务


    [root@linux3 centos7]# service httpd status
    Redirecting to /bin/systemctl status htmld.service
    Unit htmld.service could not be found.
    [root@linux3 centos7]# service httpd status
    Redirecting to /bin/systemctl status httpd.service
    ● httpd.service - The Apache HTTP Server
    Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
    Active: active (running) since 五 2020-07-10 11:23:01 CST; 3 weeks 4 days ago
    Docs: man:httpd(8)
    man:apachectl(8)
    Process: 127350 ExecReload=/usr/sbin/httpd $OPTIONS -k graceful (code=exited, status=0/SUCCESS)
    Main PID: 2663 (httpd)
    Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec"
    Tasks: 8
    Memory: 21.1M
    CGroup: /system.slice/httpd.service
    ├─ 2663 /usr/sbin/httpd -DFOREGROUND
    ├─ 69657 /usr/sbin/httpd -DFOREGROUND
    ├─127365 /usr/sbin/httpd -DFOREGROUND
    ├─127367 /usr/sbin/httpd -DFOREGROUND
    ├─127368 /usr/sbin/httpd -DFOREGROUND
    ├─127369 /usr/sbin/httpd -DFOREGROUND
    ├─127370 /usr/sbin/httpd -DFOREGROUND
    └─127371 /usr/sbin/httpd -DFOREGROUND

    Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.

    修改各个服务器yum配置文件如上一步配置yum
    只不过这里的配置改为如下:
    我这里80端口被占用了,httpd服务的端口改为了1380



    [root@linux3 centos7]# vim /etc/httpd/conf/httpd.conf
    Listen 1380
    [root@linux1 nacos]# cat /etc/yum.repos.d/httpd.repo
    [192.168.0.13]
    name=192.168.0.13
    baseurl=http://192.168.0.13:1380/centos7/
    gpgcheck=0
    enabled=1

    这样就配置完成了