Create a Local Repository on Ubuntu 13.04 Server
If you have to install software, security updates and fixes often in multiple systems in your local network, 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.
In this tutorial I will show you how to install the local repository in Ubuntu 13.04 server in two methods. If you use external hard drive, then it can be act as a portable repository. You can utilize the portable repository on multiple locations on the outside of your LAN. Both methods are very easy to set up and configure, and finally pick one of them, which suits best for your requirement.
Method 1: APT-Mirror
In this method, we are going to pull all packages from the public repository (Ubuntu main server) and save them in our local server hard drive. First install Apache server. This is important to share the packages over the network.
sk@server:~$ sudo apt-get install apache2
Now install APT-Mirror:
sk@server:~$ sudo apt-get install apt-mirror
Now, you need at least 50GB or more free space in your local or external hard drive.
For example, let us create a directory called “/myrepo“. We are going to save all packages in this directory:
sk@server:~$ sudo mkdir /myrepo
Now open the file /etc/apt/mirror.list and make the changes as shown below. Changes are shown in red color:
sk@server:~$ sudo vi /etc/apt/mirror.list ############# config ################## # ## Uncomment and Set the path of your repository folder ## set base_path /myrepo # # 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 <running host architecture> # set postmirror_script $var_path/postmirror.sh # set run_postmirror 0 ## The no of download threads ## set nthreads 20 set _tilde 0 # ############# end config ############## deb http://archive.ubuntu.com/ubuntu raring main restricted universe multiverse deb http://archive.ubuntu.com/ubuntu raring-security main restricted universe multiverse deb http://archive.ubuntu.com/ubuntu raring-updates main restricted universe multiverse [...]
In the above configuration file, you can add the Ubuntu source lists depending upon the distribution you use. I use the default 13.04 source list. Change them as per your requirements.
If you use both 32bit and 64bit architectures, you should name them separately in the above file. For example, if you use 32bit architecture, the lines should start with deb-i386 and for 64bit, they should be deb-amd64. Clear? Well, once you saved the configuration file, populate your repository using the following command:
sk@server:~$ sudo apt-mirror [sudo] password for sk: Downloading 2028 index files using 20 threads... Begin time: Wed May 29 23:23:09 2013 ...
Now the packages from public repositories are pulled and saved to your local repository. Depending upon your internet speed it will take hours or even days.
You can cancel this process at any time. Once you started it again, it will resume the downloading process where you left it off. I strongly advise you to use a fast broadband Internet connection.
Do I need to run this command every day to get new softwares/updates? No, it is not necessary. You can schedule this process using a cron job. So your machine will automatically run the apt-mirror command on a regular daily basis and will keep your repository up-to-date.
To do that, edit file /etc/cron.d/apt-mirror and uncomment the line shown in red color:
sk@server:~$ sudo vi /etc/cron.d/apt-mirror # # Regular cron jobs for the apt-mirror package # ## Uncomment ## 0 4 * * * apt-mirror /usr/bin/apt-mirror > /var/spool/apt-mirror/var/cron.log
As per the above example, the cron job will run every day morning 4am and download the packages.
As I mentioned above, all downloaded packages are kept in “/myrepo” directory on our local server.
Let us have a look under the /myrepo directory to make sure the packages are downloaded as shown below:
sk@server:~$ ls /myrepo/ mirror skel var
Now the contents of /myrepo directory should be made available over HTTP (web) to our clients. To do that, simply create a symbolic link to the /myrepo directory:
sk@server:~$ cd /myrepo/ sk@server:/myrepo$ sudo ln -s /myrepo/mirror/us.archive.ubuntu.com/ubuntu/ ubuntu
Please note: I made this article only for the testing purpose. So I didn’t download the whole public repository. I cancelled the download process after a couple of minutes.
It’s quite easy to configure in client side. Just open your client systems /etc/apt/sources.list file and add your local repository path:
sk@sk:~$ sudo vi /etc/apt/sources.list [...] deb http://192.168.1.200/ubuntu raring universe deb http://192.168.1.200/ubuntu raring main restricted deb http://192.168.1.200/ubuntu raring-updates main restricted [...]
That’s it. Here 192.168.1.200 is my Ubuntu server IP address. Now you can use your Local repository. The clients need not to be connected to the Internet to download packages. Instead, it will get all packages, updates from your Ubuntu server’s local repository.
Method 2: APT-Cacher
APT-Cacher is different from APT-Mirror. It does not mirror the entire repository contents, instead it saves the packages requested by the network clients and make them available for the rest of the clients for future use.
First install Apache server. This is required to share the packages over the network:
sk@server:~$ sudo apt-get install apache2
Now install APT-Cacher.
sk@server:~$ sudo apt-get install apt-cacher
Choose apt-cacher daemon to act as standalone and click OK.
Once you are done the installation, open the file /etc/default/apt-cacher and set autostart=1 if it is 0, else leave it as it is:
sk@server:~$ sudo vi /etc/default/apt-cacher # apt-cacher daemon startup configuration file # Set to 1 to run apt-cacher as a standalone daemon, set to 0 if you are going # to run apt-cacher from /etc/inetd or in CGI mode (deprecated). Alternatively, # invoking "dpkg-reconfigure apt-cacher" should do the work for you. # AUTOSTART=1 # extra settings to override the ones in apt-cacher.conf # EXTRAOPT=" daemon_port=3142 limit=30 " ~
You can also allow or deny the no of hosts to access the cache (packages). To do that, open the /etc/apt-cacher/apt-cacher.conf file. Uncomment and update the value for allowed_hosts to match the individual hosts. Once you all the settings, restart the service:
sk@server:~$ sudo vi /etc/apt-cacher/apt-cacher.conf [...] ## Uncomment and set the IP range ## allowed_hosts = 192.168.1.20 - 192.168.1.30 #denied_hosts = [...]
Now, create a file called /etc/apt/apt.conf.d/90-apt-proxy.conf and add the following line:
sk@server:~$ vi /etc/apt/apt.conf.d/90-apt-proxy.conf Acquire::http::Proxy "http://192.168.1.200:3142";
Replace the IP address with your server IP address.
Either you prefer the first or second method, both are highly recommended to save your internet bandwidth. Also, both are easy to configure and maintain, and you don’t to be a master In Linux.
Like us on Facebook
We need your assistance to stay live
This week Top Posts
- Top Things To Do After Installing Ubuntu 13.10 'Saucy Salamander' : Ubuntu 13.10 Saucy Salamander will be released on coming October 17th with many new salient featur...0 comments |
- Fedora 21 Scheduled For Release In October : For Fedora users, just keep calm and use Fedora 20 for now. Fedora Developers has announced that F...1 comment |
- How To Upgrade From Ubuntu 13.04 Raring To Ubuntu 13.10 Saucy Salamander : Ubuntu 13.10 Saucy will be released on October 17th. Hope it will come with lot of improvements and ...0 comments |
- Install LAMP Server (Apache, MySQL or MariaDB, PHP) On Ubuntu 13.10 : Updated January 12, 2014 LAMP is a combination of operating system and open-source software stack. ...0 comments |
- Install lamp with 1 command in Ubuntu 12.10, 13.04 Raring Ringtail & LinuxMint13 : Updated: 10/09/2012 :LAMP (Linux, Apache, MySQL and PHP) is an open source Web development platform ...0 comments |
- How to Install uTorrent Client on Ubuntu/Debian/Linux Mint : uTorrent is a lightweight and efficient BitTorrent client for Linux, Windows OS and Mac OS. The inst...0 comments |
- Fedora 21 Scheduled For Release In October
- Install Uget Download Manager In Ubuntu, Fedora, Debian
- Download Elementary OS ‘Luna’ Official Wallpapers
- Install Power Commands 0.1.5 On Ubuntu 14.04/13.10/12.10/12.04
- 5 Android Apps that’s Going to Make Running Your Business Less Stressful
- Puppet agent Install Using Script
- Install Corosync and Pacemaker On CentOS 6.5
- Install Fail2Ban On Ubuntu Server 13.04/13.10
- How To Install Google Chrome in Fedora 20, 19, 18
- How to surf using Tor Browser Bundle
This work by unixmen.com is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
Copyright © 2008-2013 Unixmen.com .