diff --git a/sources/tech/20141229 4 Steps to Setup Local Repository in Ubuntu using APT-mirror.md b/sources/tech/20141229 4 Steps to Setup Local Repository in Ubuntu using APT-mirror.md deleted file mode 100644 index f3a5a451d6..0000000000 --- a/sources/tech/20141229 4 Steps to Setup Local Repository in Ubuntu using APT-mirror.md +++ /dev/null @@ -1,127 +0,0 @@ -Translating by FSSlc - -4 Steps to Setup Local Repository in Ubuntu using APT-mirror -================================================================================ -Today we will show you how to setup a local repository in your Ubuntu PC or Ubuntu Server straight from the official Ubuntu repository. There are a lot benefit of creating a local repository in your computer if you have a lot of computers to install software, security updates and fixes often in all systems, then having a local Ubuntu repository is an efficient way. Because all required packages are downloaded over the fast LAN connection from your local server, so that it will save your Internet bandwidth and reduces the annual cost of Internet.. - -You can setup a local repository of Ubuntu in your local PC or server using many tools, but we'll featuring about APT-Mirror in this tutorial. Here, we'll be mirroring packages from the default mirror to our Local Server or PC and we'll need at least **120 GB** or more free space in your local or external hard drive. It can be configured through a **HTTP** or **FTP** server to share its software packages with local system clients. - -We'll need to install Apache Web Server and APT-Mirror to get our stuffs working out of the box. Here are the steps below to configure a working local repository: - -### 1. Installing Required Packages ### - -First of all, we are going to pull whole packages from the public repository of Ubuntu package server and save them in our local Ubuntu server hard disk. - -We'll first install a web server to host our local repository. We'll install Apache web server but you can install any web server you wish, web server are necessary for the http protocol. You can additionally install FTP servers like proftpd, vsftpd,etc if you need to configure for ftp protocols and Rsync for rsync protocols. - - $ sudo apt-get install apache2 - -And then we'll need to install apt-mirror: - - $ sudo apt-get install apt-mirror - -![apt-mirror-installation](http://blog.linoxide.com/wp-content/uploads/2014/12/apt-mirror-install.png) - -**Note: As I have already mentioned that we'll need at least 120 GBs free space to get all the packages mirrored or download.** - -### 2. Configuring APT-Mirror ### - -Now create a directory on your harddisk to save all packages. For example, let us create a directory called “/linoxide”. We are going to save all packages in this directory: - - $ sudo mkdir /linoxide - -![repo-dir](http://blog.linoxide.com/wp-content/uploads/2014/12/mkdir-linoxide.png) - -Now, open the file **/etc/apt/mirror.list** file - - $ sudo nano /etc/apt/mirror.list - -![apt-mirror-edit](http://blog.linoxide.com/wp-content/uploads/2014/12/edit-mirror-list-300x7.png) - -Copy the below lines of configuration to mirror.list and edit as your requirements. - - ############# config ################## - # - set base_path /linoxide - # - # set mirror_path $base_path/mirror - # set skel_path $base_path/skel - # set var_path $base_path/var - # set cleanscript $var_path/clean.sh - # set defaultarch - # 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 - -![mirror-list-config](http://blog.linoxide.com/wp-content/uploads/2014/12/mirror-list-config.png) - -**Note: You can replace the above official mirror server url by the nearest one, you can get your nearest server by visiting the page [Ubuntu Mirror Server][1]. If you are not in hurry and can wait for the mirroring, you can go with the default official one.** - -Here, we are going to mirror package repository of the latest and greatest LTS release of Ubuntu ie. Ubuntu 14.04 LTS (Trusty Tahr) so, we have configured trusty. If you need to mirror of Saucy or other version of Ubuntu, please edit it as its codename. - -Now, we'll have to run apt-mirror which will now get/mirror all the packages in the repository. - - sudo apt-mirror - -It will take time to download all the packages from the Ubuntu Server which depends upon the connection speed and performance with respect to you and the mirror server. I have interrupted the download as I have already done that... - -![downloading-packages](http://blog.linoxide.com/wp-content/uploads/2014/12/downloading-index.png) - -### 3.Configuring Web Server ### - -To be able to access the repo from other computers you need a webserver. You can also do it via ftp but I choose to use a webserver as I mentioned in above step 1. So, we are now gonna configure Apache Server: - -We will create a symlink from our local repo's directory to a directory ubuntu in the hosting directory of Apache ie /var/www/ubuntu - - $ sudo ln -s /linoxide /var/www/ubuntu - $ sudo service apache2 start - -![symlinks-apache2](http://blog.linoxide.com/wp-content/uploads/2014/12/symblink-apache2.png) - -The above command will allow us to browse our Mirrored Repo from our localhost ie http://127.0.0.1 by default. - -### 4. Configuring Client Side ### - -Finally, we need to add repository source in other computers which will fetch the packages and repository from our computer. To do that, we'll need to edit /etc/apt/sources.list and add the following lines. - - $ sudo nano /etc/apt/sources.list - -Add this line in /etc/apt/sources.list and save. - - deb http://192.168.0.100/ubuntu/ trusty main restricted universe - -**Note: here 192.168.0.100 is the LAN IP address of our server computer, you need to replace that with yours.** - - $ sudo apt-get update - -Finally, we are done. Now you can install the required packages using sudo apt-get install packagename from your local Ubuntu repository with high speed download and with low bandwidth. - --------------------------------------------------------------------------------- - -via: http://linoxide.com/ubuntu-how-to/setup-local-repository-ubuntu/ - -作者:[Arun Pyasi][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出 - -[a]:http://linoxide.com/author/arunp/ -[1]:https://launchpad.net/ubuntu/+archivemirrors diff --git a/translated/tech/20141229 4 Steps to Setup Local Repository in Ubuntu using APT-mirror.md b/translated/tech/20141229 4 Steps to Setup Local Repository in Ubuntu using APT-mirror.md new file mode 100644 index 0000000000..c49b52c461 --- /dev/null +++ b/translated/tech/20141229 4 Steps to Setup Local Repository in Ubuntu using APT-mirror.md @@ -0,0 +1,125 @@ +在 Ubuntu中使用 APT-mirror 简单四步配置本地软件仓库 +================================================================================ +今天,我们将向你展示如何在你的 Ubuntu 个人电脑 或 Ubuntu 服务器 中,直接通过 Ubuntu 官方软件仓库来配置本地软件仓库。在你的电脑中创建一个本地软件仓库有着许多的好处。假如你有许多电脑需要安装软件,安全升级和修复,那么配置一个本地软件仓库是一个高效的方法。因为,所有需要安装的软件包都可以通过快速局域网连接从你的本地服务器中下载,这样可以节省你的网络带宽,降低互联网的年度开支 ... + +你可以使用多种工具在你的本地个人电脑或服务器中配置一个 Ubuntu 的本地软件仓库,但在本教程中,我们将为你介绍 APT-Mirror。这里,我们将把默认的镜像包镜像到 我们本地的服务器或个人电脑中,并且在本地或外置硬盘中,我们至少需要 **120 GB** 或更多的可用空间。 上面的任务可以通过配置一个 **HTTP** 或 **FTP** 服务器来 与本地系统客户端共享软件包。 + +我们需要安装 Apache 网络服务器和 APT-Mirror 来使得我们的工作得以开始。下面是配置一个可工作的本地软件仓库的步骤: + +### 1. 安装需要的软件包 ### + +首先,我们需要从 Ubuntu 的公共软件包仓库中取得所有的软件包,然后在我们本地的 Ubuntu 服务器硬盘中保存它们。 + +首先我们安装一个网络服务器来承载我们的本地软件仓库。这里我们将安装 Apache 网络服务器,但你可以安装任何你中意的网络服务器,对于 http 协议,网络服务器是必须的。假如你需要配置 ftp 协议 及 rsync 协议,你还可以再分别额外安装 FTP 服务器,如 proftpd, vsftpd 等等 和 Rsync 。 + + $ sudo apt-get install apache2 + +然后我们需要安装 apt-mirror: + + $ sudo apt-get install apt-mirror + +![apt-mirror-installation](http://blog.linoxide.com/wp-content/uploads/2014/12/apt-mirror-install.png) + +**注: 正如我先前提到的,我们需要至少 120 GB 的可用空间来使得所有的软件包被镜像或下载。** + +### 2. 配置 APT-Mirror ### + +现在,在你的硬盘上创建一个目录来保存所有的软件包。例如,我们创建一个名为 `/linoxide`的目录,我们将在这个目录中保存所有的软件包: + + $ sudo mkdir /linoxide + +![repo-dir](http://blog.linoxide.com/wp-content/uploads/2014/12/mkdir-linoxide.png) + +现在,打开文件 **/etc/apt/mirror.list** : + + $ sudo nano /etc/apt/mirror.list + +![apt-mirror-edit](http://blog.linoxide.com/wp-content/uploads/2014/12/edit-mirror-list-300x7.png) + +复制下面的命令行配置到 `mirror.list`文件中并按照你的需求进行修改: + + ############# config ################## + # + set base_path /linoxide + # + # set mirror_path $base_path/mirror + # set skel_path $base_path/skel + # set var_path $base_path/var + # set cleanscript $var_path/clean.sh + # set defaultarch + # 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 + +![mirror-list-config](http://blog.linoxide.com/wp-content/uploads/2014/12/mirror-list-config.png) + +**注: 你可以将上面的官方镜像服务器网址更改为离你最近的服务器的网址,而这可以访问 [Ubuntu Mirror Server][1]来得到。假如你并不着急并可以等待镜像的完成,你可以沿用默认的官方镜像服务器网址。** + +这里,我们将要镜像 最新和最大的 Ubuntu LTS 发行版 --- 即 Ubuntu 14.04 LTS (Trusty Tahr) --- 的软件包仓库,所以在上面的配置中发行版本号为 trusty 。假如我们需要镜像 Saucy 或其他的 Ubuntu 发行版本,请修改上面的 trusy 为相应的代号。 + +现在,我们必须运行 apt-mirror 来下载或镜像 官方仓库中的所有软件包。 + + sudo apt-mirror + +从 Ubuntu 服务器中下载所有的软件包所花费的时间取决于 你和镜像服务器之间的网络连接速率和性能。我已经中断了下载,因为我已经下载好了 ... + +![downloading-packages](http://blog.linoxide.com/wp-content/uploads/2014/12/downloading-index.png) + +### 3.配置网络服务器 ### + +为了使得其他的电脑能够取得这个软件仓库,你需要一个网络服务器。你也可以通过 ftp 来完成这件事,但我选择使用一个网络服务器因为在上面的步骤 1 中我提及到使用网络服务器。因此,我们现在要对 Apache 服务器进行配置: + +我们将为我们本地的软件仓库目录 建立一个到 Apache 托管目录 --- 即 `/var/www/ubuntu` --- 的符号链接。 + + $ sudo ln -s /linoxide /var/www/ubuntu + $ sudo service apache2 start + +![symlinks-apache2](http://blog.linoxide.com/wp-content/uploads/2014/12/symblink-apache2.png) + +上面的命令将允许我们从本地主机(localhost) --- 即 http://127.0.0.1(默认情况下) --- 浏览我们的镜像软件仓库。 + +### 4. 配置客户端 ### + +最后,我们需要在其他的电脑中添加软件源,来使得它们可以从我们的电脑中取得软件包或软件仓库。为达到此目的,我们需要编辑 `/etc/apt/sources.list` 文件并添加下面的命令: + + $ sudo nano /etc/apt/sources.list + +添加下面的一行到` /etc/apt/sources.list`中并保存。 + + deb http://192.168.0.100/ubuntu/ trusty main restricted universe + +**注: 这里的 192.168.0.100 是我们的服务器电脑的 局域网 IP 地址,你需要替换为你的服务器电脑的局域网 IP 地址** + + $ sudo apt-get update + +最终,我们完成了任务。现在,你可以使用`sudo apt-get install packagename` 命令来从你的本地 Ubuntu 软件仓库中安装所需的软件包,这将会是高速的且消耗很少的带宽。 + +-------------------------------------------------------------------------------- + +via: http://linoxide.com/ubuntu-how-to/setup-local-repository-ubuntu/ + +作者:[Arun Pyasi][a] +译者:[FSSlc](https://github.com/FSSlc) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出 + +[a]:http://linoxide.com/author/arunp/ +[1]:https://launchpad.net/ubuntu/+archivemirrors