在Ubuntu系统中使用APT-mirror本地软件仓库的教程

2020-02-03 13:18:26于丽

# set cleanscript $var_path/clean.sh
# set defaultarch <running host architecture>
# set postmirror_script $var_path/postmirror.sh
# set run_postmirror 0
set nthreads 20
set _tilde 0
#
############# end config ##############

deb http://archive.ubuntu.com/ubuntu trusty main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu trusty-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse
#deb http://archive.ubuntu.com/ubuntu trusty-proposed main restricted universe multiverse
#deb http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse

deb-src http://archive.ubuntu.com/ubuntu trusty main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu trusty-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse
#deb-src http://archive.ubuntu.com/ubuntu trusty-proposed main restricted universe multiverse
#deb-src http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse

clean http://archive.ubuntu.com/ubuntu

注: 你可以将上面的官方镜像服务器网址更改为离你最近的服务器的网址,可以通过访问 Ubuntu Mirror Server来找到这些服务器地址。假如你并不太在意镜像完成的时间,你可以沿用默认的官方镜像服务器网址。

这里,我们将要镜像最新和最大的 Ubuntu LTS 发行版 --- 即 Ubuntu 14.04 LTS (Trusty Tahr) --- 的软件包仓库,所以在上面的配置中发行版本号为 trusty 。假如我们需要镜像 Saucy 或其他的 Ubuntu 发行版本,请修改上面的 trusy 为相应的代号。

现在,我们必须运行 apt-mirror 来下载或镜像官方仓库中的所有软件包。

   
复制代码sudo apt-mirror

从 Ubuntu 服务器中下载所有的软件包所花费的时间取决于你和镜像服务器之间的网络连接速率和性能。这里我中断了下载,因为我已经下载好了 ...
2015610170011298.png (529×66)

3.配置网络服务器

为了使得其他的电脑能够访问这个软件仓库,你需要一个Web服务器。你也可以通过 ftp 来完成这件事,但我选择使用一个Web服务器因为在上面的步骤 1 中我提及到使用Web服务器。因此,我们现在要对 Apache 服务器进行配置:

我们将为我们本地的软件仓库目录 建立一个到 Apache 托管目录 --- 即 /var/www/ubuntu --- 的符号链接。

   
复制代码$ sudo ln -s /linoxide /var/www/ubuntu
$ sudo service apache2 start

上面的命令将允许我们从本地主机(localhost) --- 即 http://127.0.0.1(默认情况下) --- 浏览我们的镜像软件仓库。