在Debian系统中,通常使用APT包管理器而不是YUM。YUM是Red Hat系列发行版(如Fedora、CentOS)的包管理器。不过,如果你想在Debian系统上创建一个本地仓库,你可以使用APT的apt-mirror
工具或者手动设置一个本地APT仓库。以下是两种方法的步骤:
安装apt-mirror:
sudo apt-get update
sudo apt-get install apt-mirror
配置apt-mirror:
编辑/etc/apt/mirror.list
文件,根据你的需求选择合适的镜像站点和要镜像的目录。例如:
set base_path /var/spool/apt-mirror/mirror/
set skel_path $base_path/skel/
set var_path $base_path/var/
set cleanscript $var_path/clean.sh
set defaultarch amd64
set postmirror_script $var_path/postmirror.sh
set run_postmirror 0
deb mirror://mirrors.ustc.edu.cn/debian/ bullseye main contrib non-free
deb mirror://mirrors.ustc.edu.cn/debian/ bullseye-updates main contrib non-free
deb mirror://mirrors.ustc.edu.cn/debian/ bullseye-backports main contrib non-free
deb mirror://mirrors.ustc.edu.cn/debian-security/ bullseye/updates main contrib non-free
执行镜像同步:
sudo apt-mirror
配置本地APT使用本地仓库:
编辑/etc/apt/sources.list
文件,将其中的官方仓库地址替换为本地仓库的地址。例如:
deb file:///var/spool/apt-mirror/mirror/debian/ bullseye main contrib non-free
deb file:///var/spool/apt-mirror/mirror/debian/ bullseye-updates main contrib non-free
deb file:///var/spool/apt-mirror/mirror/debian/ bullseye-backports main contrib non-free
deb file:///var/spool/apt-mirror/mirror/debian-security/ bullseye/updates main contrib non-free
更新本地仓库索引:
sudo apt-get update
下载Debian包:
你可以从Debian官方网站或其他镜像站点下载所需的.deb
包到本地目录。
创建本地仓库目录:
sudo mkdir -p /var/www/html/debian
复制.deb包到本地仓库目录:
将下载的.deb
包复制到/var/www/html/debian
目录下。
配置APT使用本地仓库:
编辑/etc/apt/sources.list
文件,添加本地仓库的地址。例如:
deb [trusted=yes] file:/var/www/html/debian ./
更新本地仓库索引:
sudo apt-get update
通过以上两种方法,你可以在Debian系统上创建并使用本地APT仓库。选择哪种方法取决于你的具体需求和偏好。