当前位置: 首页 > Linux

创建本地APT软件包存储库

时间:2023-04-06 19:19:28 Linux

由于某些安全原因,有时Ubuntu机器无法连接到互联网。在这种情况下,您可以设置自己的本地APT包存储库并在Ubuntu机器上安装这些包。系统环境Ubuntu20.04LTS安装dpkg-dev需要安装dpkg-dev包,为本地APT仓库创建包元数据。bob@ubuntu-20-04:~$sudoaptinstall-ydpkg-devinstallhttpservice如果软件仓库需要被其他ubuntu20.04服务器使用,可以安装一个web服务器为其他ubuntu20.04服务器提供软件仓库.bob@ubuntu-20-04:~$sudoaptinstall-yapache2创建本地仓库存放目录创建/var/www/html/repo目录存放软件包:bob@ubuntu-20-04:~$sudo用mkdir/var/www/html/repo创建挂载点,将ubuntu20.04光盘挂载到/mnt/cdrom目录下。bob@ubuntu-20-04:~$sudomkdir/mnt/cdrombob@ubuntu-20-04:~$sudomount/dev/cdrom/mnt/cdrommount:/mnt/cdrom:警告:设备写保护,挂载只读。在/mnt/cdrom中找到所有deb包并将它们复制到我们本地的APT存储库目录中。bob@ubuntu-20-04:~$sudofind/mnt/cdrom-iname"*.deb"-execcp{}/var/www/html/repo\;在Ubuntu20.04中创建一个本地APT包存储库Ubuntu20.04创建一个本地APT包存储库编写一个脚本来更新Package.gz文件创建一个脚本文件来扫描Packages.gz文件的更新,因为您可能会向您的不时访问本地APT存储库。因此,每次在repo目录中添加新的deb包后,都需要更新Packages.gz文件。bob@ubuntu-20-04:~$sudovim/bin/update-debs!/bin/bashcd/var/www/html/repodpkg-scanpackages。/开发/空|gzip-9c>Packages.gzforupdate-debs脚本文件添加可执行权限:bob@ubuntu-20-04:~$sudochmod+x/bin/update-debs现在执行这个脚本来创建Packages.gz文件:bob@ubuntu-20-04:~$sudo/bin/update-debs在sources.list文件中添加本地APT仓库的地址。首先备份sources.list文件,然后添加:https://www.51cto.com/it/news...https://www.donews.com/news/d...https://www.pcpop.com/article...bob@ubuntu-20-04:~$cd/etc/apt/bob@ubuntu-20-04:/etc/apt$sudocp-psources.listsources.list.back打开sources.list文件,在文件底部添加如下内容:bob@ubuntu-20-04:/etc/apt$sudovimsources。listLocalAPTRepositorydeb[allow-insecure=yes]http://192.168.43.174/repo./Ubuntu20.04创建本地APT软件包仓库在Ubuntu20.04创建本地APT软件包仓库更新软件源:bob@ubuntu-20-04:~$sudoaptupdateUbuntu20.04创建本地APT包仓库在Ubuntu20.04中创建本地APT包仓库总结在本文中,我介绍了如何在Ubuntu20.04LTS上创建本地APT仓库。