有的时候我们的Ubuntu是在我网络的环境下运行的,这就对Ubuntu apt这种需要网络在线下载的安装方式来说是极大不便的,所以需要制作离线包。Ubuntu离线安装软件原理是,在正常有网的开发服务器上安装所有依赖内容,并制作为本地源包,在目标服务器上解压后映射本地源,进行无外网安装。
制作本地源(有网络主机端)
1、配置源(此步骤其实可以省略)
//备份原来的源文件
mv /etc/apt/sources.list /etc/apt/sources.list.bak
//写入新的源配置,这里也可以用vi cat >>/etc/apt/sources.list <<EOF deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse EOF
//更新源 apt-get update apt-get upgrade
2、安装离线所需的包
//根绝需求使用apt-get安装自己需要的包,比如: apt-get install openssh-server apt-get install -y sysstat apt-get install -y gawk apt-get install -y bc apt-get install -y unzip apt-get install -y wget
3、制作离线包
cd /var/cache/apt/archives/
dpkg-scanpackages . | gzip -9c > Packages.gz
tar -zcf packages.tar.gz ./*
packages.tar.gz
就是制作好的离线包
内网安装
1、上传离线包
上传之前制作的离线包packages.tar.gz
2、建立离线源
# 创建离线文件存放目录 mkdir -p /offline/packages # 解压离线文件 tar -zxvf packages.tar.gz -C /offline/packages/ # 备份源文件 mv /etc/apt/sources.list /etc/apt/sources.list.bak # 映射本地源,这里可以使用vi cat >>/etc/apt/sources.list <<EOF deb [trusted=yes] file:///offline/packages/ ./ EOF # 更新 apt-get update
3、安装
//根据自己需求进行安装,例如: apt-get install -y wget apt-get install -y gawk
标签:get,list,离线,apt,sources,install,ubuntu,安装 From: https://www.cnblogs.com/yangrourou/p/17840293.html