<p id="1NDN27GP"><strong>我们将向你展示如何在你的 Ubuntu 个人电脑或 Ubuntu 服务器中,直接通过 Ubuntu 官方软件仓库来配置本地。在你的电脑中创建一个本地软件仓库有着许多的好处。假如你有许多电脑需要安装软件 、安全升级和修复补丁,那么配置一个本地软件仓库是一个做这些事情的高效方法。因为,所有需要安装的软件包都可以通过快速的局域网连接从你的本地中下载,这样可以节省你的网络带宽,降低互联网接入的年度开支。</strong></p><p id="1NDN27GQ"><strong>介绍APT-Mirror</strong></p><p id="1NDN27GR">你可以使用多种工具在你的本地个人电脑或服务器中配置一个 Ubuntu 的本地软件仓库,但在本教程中,我们将为你介绍 APT-Mirror。这里,我们将把默认的镜像包镜像到我们本地的服务器或个人电脑中,并且在你的本地或外置硬盘中,我们至少需要 120 GB 或更多的可用空间才行。 我们可以通过配置一个 HTTP 或 FTP 服务器来与本地系统客户端共享这个软件仓库。</p><p id="1NDN27GT">我们需要安装 Apache 网络服务器和 APT-Mirror 来使得我们的工作得以开始。下面是配置一个可工作的本地软件仓库的步骤:</p><p id="1NDN27GU"><strong>1. 安装需要的</strong></p><p id="1NDN27GV">我们需要从 Ubuntu 的公共软件包仓库中取得所有的软件包,然后在我们本地的 Ubuntu 服务器硬盘中保存它们。</p><p id="1NDN27H0">首先我们安装一个Web 服务器来承载我们的本地软件仓库。这里我们将安装 Apache Web 服务器,但你可以安装任何你中意的 Web 服务器。对于 http 协议,Web 服务器是必须的。假如你需要配置 ftp 协议 及 rsync 协议,你还可以再分别额外安装 FTP 服务器,如 prod, vsftpd 等等 和 Rsync 。</p><p id="1NDN27H1">1.$ sudo apt-get install apache2</p><p id="1NDN27H2">然后我们需要安装 -mirror:</p><p id="1NDN27H3">1.$ sudo apt-get install apt-mirror</p><p id="1NDN27H5"><strong>2. 配置 APT-Mirror</strong></p><p id="1NDN27H6">现在,在你的硬盘上创建一个目录来保存所有的软件包。例如,我们创建一个名为 /linoxide的目录,我们将在这个目录中保存所有的软件包:</p><p id="1NDN27H7">1. $ sudo mkdir /linoxide</p><p id="1NDN27H8">现在,打开文件 /etc/apt/mirror.list :</p><p id="1NDN27H9">1. $ sudo nano /etc/apt/mirror.list</p><p id="1NDN27HA">复制下面的命令行配置到 mirror.list文件中并按照你的需求进行修改:</p><p id="1NDN27HB">1. config <br/>2.#<br/>3.set base_path /linoxide<br/>4.#<br/>5.# set mirror_path $base_path/mirror<br/>6.# set skel_path $base_path/skel<br/>7.# set var_path $base_path/var<br/>8.# set cleanscript $var_path/clean.sh<br/>9.# set defaultarch</p><p id="1NDN27HC">10.# set postmirror_script $var_path/postmirror.sh11.# set run_postmirror 012.set nthreads 2013.set _tilde 014.#15. end config 16. 17.deb http://archive.ubuntu.com/ trusty main restricted universe multiverse18.deb http://archive.ubuntu.com/ubuntu trusty-security main restricted universe multiverse19.deb http://archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse20.#deb http://archive.ubuntu.com/ubuntu trusty-proposed main restricted universe multiverse21.#deb http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse22. 23.deb-src http://archive.ubuntu.com/ubuntu trusty main restricted universe multiverse24.deb-src http://archive.ubuntu.com/ubuntu trusty-security main restricted universe multiverse25.deb-src http://archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse26.#deb-src http://archive.ubuntu.com/ubuntu trusty-proposed main restricted universe multiverse27.#deb-src http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse28. 29.clean http://archive.ubuntu.com/</p><p id="1NDN27HD">这里,我们将要镜像最新和最大的 Ubuntu LTS 发行版 --- 即 Ubuntu 14.04 LTS (Trusty Tahr) --- 的软件包仓库,所以在上面的配置中发行版本号为 trusty 。假如我们需要镜像 Saucy 或其他的 Ubuntu 发行版本,请修改上面的 trusy 为相应的代号。</p><p id="1NDN27HE">现在,我们必须运行 apt-mirror 来下载或镜像官方仓库中的所有软件包。</p><p id="1NDN27HF">1.sudo apt-mirror</p><p id="1NDN27HG">从 Ubuntu 服务器中下载所有的软件包所花费的时间取决于你和镜像服务器之间的网络连接速率和性能。这里我中断了下载,因为我已经下载好了 ...</p><p id="1NDN27HI"><strong>3.配置网络服务器</strong></p><p id="1NDN27HJ">为了使得其他的电脑能够访问这个软件仓库,你需要一个Web服务器。你也可以通过 ftp 来完成这件事,但我选择使用一个Web服务器因为在上面的步骤 1 中我提及到使用Web服务器。因此,我们现在要对 Apache 服务器进行配置:</p><p id="1NDN27HK">我们将为我们本地的软件仓库目录 建立一个到 Apache 托管目录 --- 即 /var/www/ubuntu --- 的符号链接。</p><p id="1NDN27HL">1.$ sudo ln -s /linoxide /var/www/ubuntu<br/>2.$ sudo service apache2 start</p><p id="1NDN27HM">上面的命令将允许我们从本地主机(localhost) --- 即 http://127.0.0.1(默认情况下) --- 浏览我们的镜像软件仓库。</p><p id="1NDN27HN"><strong>4. 配置客户端</strong></p><p id="1NDN27HO">最后,我们需要在其他的电脑中添加软件源,来使得它们可以从我们的电脑中取得软件包或软件仓库。为达到此目的,我们需要编辑 /etc/apt/sources.list 文件并添加下面的命令:</p><p id="1NDN27HP">1.$ sudo nano /etc/apt/sources.list</p><p id="1NDN27HQ">添加下面的一行到/etc/apt/sources.list中并保存。</p><p id="1NDN27HR">1.deb http://192.168.0.100/ubuntu/ trusty main restricted universe</p><p id="1NDN27HS">注: 这里的 192.168.0.100 是我们的服务器电脑的局域网 IP 地址,你需要替换为你的服务器电脑的局域网 IP 地址</p><p id="1NDN27HT">1.$ sudo apt-get update</p><p id="1NDN27HU">最终,我们完成了任务。现在,你可以使用sudo apt-get install packagename 命令来从你的本地 Ubuntu 软件仓库中安装所需的软件包,这将会是高速的且消耗很少的带宽。</p><p><blockquote id="1NDN27I1"><ul><li id="1NDN27HV">原文来自:https://www.linuxprobe.com/apt-mirror-yum.html</li><li id="1NDN27I0">本文地址:https://linux.cn/article-4926-1.html</li></ul></blockquote></p>
讯享网

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/193594.html