当前位置:   article > 正文

Debian OS本地及局域网apt源搭建_debian配置apt源

debian配置apt源

一、本地apt源搭建

1.1、上传ISO镜像到本地OS

上传dvd1.iso,dvd2.iso,dvd3iso镜像到系统下

# mkdir /root/ISO
# ls -l debian-10.6.0-amd64-DVD-*
-rw-r--r-- 1 root root 3972317184 Apr 18 08:55 debian-10.6.0-amd64-DVD-1.iso
-rw-r--r-- 1 root root 4686921728 Apr 18 08:55 debian-10.6.0-amd64-DVD-2.iso
-rw-r--r-- 1 root root 4640186368 Apr 18 08:54 debian-10.6.0-amd64-DVD-3.iso
  • 1
  • 2
  • 3
  • 4
  • 5

1.2、挂载ISO镜像

  • 手动挂载
# mkdir /mnt/source{1..3}
mount -o loop  /root/ISO/debian-10.6.0-amd64-DVD-1.iso /mnt/source1
mount -o loop  /root/ISO/debian-10.6.0-amd64-DVD-2.iso /mnt/source2
mount -o loop  /root/ISO/debian-10.6.0-amd64-DVD-3.iso /mnt/source3
  • 1
  • 2
  • 3
  • 4
  • 设置开机自动挂载
    在/etc/fstab后追加如下内容设置开机自动挂载
# vim /etc/fstab
/root/ISO/debian-10.6.0-amd64-DVD-1.iso /mnt/source1 udf,iso9660 user,loop 0 0
/root/ISO/debian-10.6.0-amd64-DVD-2.iso /mnt/source2 udf,iso9660 user,loop 0 0
/root/ISO/debian-10.6.0-amd64-DVD-3.iso /mnt/source3 udf,iso9660 user,loop 0 0
  • 1
  • 2
  • 3
  • 4

1.3、编辑apt配置文件

# vim /etc/apt/sources.list

deb [trusted=yes] file:///mnt/source1 buster contrib main
deb [trusted=yes] file:///mnt/source2 buster contrib main
deb [trusted=yes] file:///mnt/source3 buster contrib main
  • 1
  • 2
  • 3
  • 4
  • 5

配置文件中 buster 是debian10的代号,若为其他版本需要改为对应代号

  • Debian 11 (bullseye) — 當前的穩定(stable)版
  • Debian 10(buster) — 當前的舊的穩定(oldstable)版,現有長期支持
  • Debian 9(stretch) — 更舊的穩定(oldoldstable)版,現有擴展長期支持
  • Debian 8(jessie) — 已存檔版本,現有擴展長期支持

1.4、验证apt源

apt update
apt install vim
  • 1
  • 2

二、局域网apt源搭建

此文搭建apt源的http Server配置如下

OS: CentOS 7U6,
IP: 192.168.15.10

2.1、 安装Http服务和xml生成工具,由于安装系统时已经顺便安装了相应的安装包,所以此处无须再进行安装。

[root@simonlinux ~]# yum install httpd createrepo
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Repository base is listed more than once in the configuration
Package httpd-2.4.6-88.el7.x86_64 already installed and latest version
Package createrepo-0.9.9-28.el7.noarch already installed and latest version
Nothing to do
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

2.2、 新建存放yum源文件的目录并将相关文件复制进去

[root@simonlinux smb]# ls -l
-rw-r--r-- 1 root root 3972317184 Apr 18 08:55 debian-10.6.0-amd64-DVD-1.iso
-rw-r--r-- 1 root root 4686921728 Apr 18 08:55 debian-10.6.0-amd64-DVD-2.iso
-rw-r--r-- 1 root root 4640186368 Apr 18 08:54 debian-10.6.0-amd64-DVD-3.iso
[root@simonlinux smb]# mkdir  /mnt/source{1..3}
[root@simonlinux smb]# mount -o loop debian-10.6.0-amd64-DVD-1.iso /mnt/source1
mount: /dev/loop0 is write-protected, mounting read-only
[root@simonlinux smb]# mount -o loop debian-10.6.0-amd64-DVD-2.iso /mnt/source2
mount: /dev/loop0 is write-protected, mounting read-only
[root@simonlinux smb]# mount -o loop debian-10.6.0-amd64-DVD-3.iso /mnt/source3
mount: /dev/loop0 is write-protected, mounting read-only
[root@simonlinux ~]# mkdir -p /var/www/html/apt_sosurce/debian/10u6/source{1..3}
[root@simonlinuxt ~]# rsync -avh /mnt/source1 /var/www/html/apt_source/debian/10u6/source1
[root@simonlinux ~]# rsync -avh /mnt/source2 /var/www/html/apt_source/debian/10u6/source2
[root@simonlinux ~]# rsync -avh /mnt/source3 /var/www/html/apt_source/debian/10u6/source3
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

2.3、启动http服务

[root@simonlinux ~]# systemctl restart httpd
[root@simonlinux ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2023-04-19 22:26:29 CST; 7s ago
     Docs: man:httpd(8)
           man:apachectl(8)
  Process: 15983 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=0/SUCCESS)
 Main PID: 15989 (httpd)
   Status: "Processing requests..."
    Tasks: 8
   CGroup: /system.slice/httpd.service
           ├─15989 /usr/sbin/httpd -DFOREGROUND
           ├─15990 /usr/libexec/nss_pcache 491523 off
           ├─15994 /usr/sbin/httpd -DFOREGROUND
           ├─15995 /usr/sbin/httpd -DFOREGROUND
           ├─15996 /usr/sbin/httpd -DFOREGROUND
           ├─15997 /usr/sbin/httpd -DFOREGROUND
           └─15998 /usr/sbin/httpd -DFOREGROUND

Apr 19 22:26:29 simonlinux.com systemd[1]: Starting The Apache HTTP Server...
Apr 19 22:26:29 simonlinux.com systemd[1]: Started The Apache HTTP Server. 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22

发现网页端无法打开,将网站端口添加到防火墙规则里并重启防火墙

[root@simonlinux ~]# firewall-cmd --add-port=80/tcp --permanent 
success
[root@simonlinux ~]# systemctl restart firewalld.service
[root@simonlinux ~]# firewall-cmd --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: eno1
sources: 
services: dhcpv6-client ssh
ports: 5901-5905/tcp 80/tcp
protocols: 
masquerade: no
forward-ports: 
source-ports: 
icmp-blocks: 
rich rules: 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17

设置http服务开机启动

[root@simonlinux ~]# systemctl enable httpd
  • 1

2.3、编辑本地apt配置文件

# vim /etc/apt/sources.list

deb [trusted=yes] http://192.168.15.10/apt_source/debian/10u6/source1 buster contrib main
deb [trusted=yes] http://192.168.15.10/apt_source/debian/10u6/source2 buster contrib main
deb [trusted=yes] http://192.168.15.10/apt_source/debian/10u6/source3 buster contrib main
  • 1
  • 2
  • 3
  • 4
  • 5

配置文件中 buster 是debian10的代号,若为其他版本需要改为对应代号

  • Debian 11 (bullseye) — 當前的穩定(stable)版
  • Debian 10(buster) — 當前的舊的穩定(oldstable)版,現有長期支持
  • Debian 9(stretch) — 更舊的穩定(oldoldstable)版,現有擴展長期支持
  • Debian 8(jessie) — 已存檔版本,現有擴展長期支持

2.4、验证apt源

apt update
apt install vim
  • 1
  • 2
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/208724
推荐阅读
相关标签
  

闽ICP备14008679号