For software, since we will be hosting a mirror, it should be able to support multiple connections and optimize the user download experience. It also doesn't have to run on expensive hardware and should be able to run on your 5 year old PIII box with 256mb memory. Hence, I have decided to use lighttpd to host the server as it is a very light weight, easy to configure and has very good performance in limited memory situations.
The apt-mirror software facilitates the download of the mirror over http and creating the required local filesystem structure on the servers local HDD for debian and apt based linux systems.
Note: It is also advisable to run the mirror using a subdomain similar to mirror.mydomain.com so that it looks clean and easy to remember for the user.
sudo apt-get install lighttpd
this will install lighttpd and its dependencies.
ls -l /var/www
will check to see if the www folder, which is where the lighttpd server's root folder is located by default, exists or not.
If not create it using
sudo mkdir /var/www
sudo chown www-data:www-data /var/www
Note: The reconfiguration of lighttpd is out of scope of this tutorial, so please refer a lighttpd config tutorial on the internet. Google also has a lot of good tutorials.
Modify /etc/apt/sources.list to include the apt-mirror repo as shown below
sudo vi /etc/apt/sources.list
add the following:
[…]
deb http://apt-mirror.sourceforge.net/ apt-mirror/
[…]\\
Run apt-get update to update the packages list to include apt-mirror
sudo apt-get update
The following will install apt-mirror.
sudo apt-get install apt-mirror
Now its time to configure apt-mirror's config file. The config file can be found under /etc/apt/mirror.list
Edit the file to look like the config below, you can even copy paste it and should work as expected.
##
## Example sources
##
# bodhi section
deb http://packages.bodhilinux.com/bodhi/ lucid main
##
## Cleaner configuration example
##
#
# set cleanscript $var_path/clean.sh
# Cleaning section
clean http://packages.bodhilinux.com/bodhi/
Now its time to download the entire Bodhi repo. Be warned that this could take a while and depends on the download speed of your internet connection.
sudo apt-mirror
apt-mirror will tell you how many GB its has to download and how long it will take. The files will be saved to /var/spool/apt-mirror/mirror/ so ensure that you have space on the partition.
Once apt-mirror is done we need to clean up any unnecessary folders and packages.
Run the command:
/bin/bash /var/spool/apt-mirror/var/clean.sh
now lets make the symlinks for lighttpd to host the repo
ln -s/var/spool/apt-mirror/mirror/packages.bodhilinux.com/bodhi /var/www/bodhi
now go to http://myserver.com/bodhi/ and it should show something similar to the below data.
Index of /bodhi/
Name Last Modified Size Type
Parent Directory/ - Directory
dists/ 2011-Jun-25 09:13:04 - Directory
pool/ 2011-Jun-25 09:10:29 - Directory
Gazoo
To schedule a cron job simply edit the file /etc/cron.d/apt-mirror by uncommenting the line
0 4 * * * apt-mirror /usr/bin/apt-mirror > /var/spool/apt-mirror/var/cron.log
This will run apt-mirror everyday and write the log out to /var/spool/apt-mirror/var/cron.log
To update manually simply run
sudo apt-mirror
sudo vi /etc/apt/sources.list
enter sudo password
Comment out the main bodhi repo (packages.bodhilinux.com) by placing a # at the beginning of the line and then type in the below line.
deb http://myserver.com/bodhi lucid main
The mirrors should have the exact same packages as the main repo, it will be updated and synced with main repo every friday.
sudo apt-get update
The best part about hosting with lighttpd is that you can customize it to run according to your needs by making simple configuration changes.
The server can be tweaked easily by editing the file /etc/lighttpd/lighttpd.conf .
sudo vi /etc/lighttpd/lighttpd.conf
add the following two lines to the file,
connection.kbytes-per-second = 150
this will set the server to allow a maximum download speed to 150 Kb/sec
server.tag = “Gazoo”
this line will rename the display name of the server to something other than lighttpd, in this case, Gazoo.
If you would like to comment or make further suggestions, please leave a note on our Comments page (you will have to Create an Account if you haven't already).