Monday, February 16, 2015

How to setup your own ubuntu package repository

*** Requirement and information
- disk space 1Tb or more,
- the repository domain is deb.repo, so you can create a record or edit hosts file to point the domain to the ip you are gonna host the repository

1- create a directory all package and  download all the package from mirrors
$ mkdir /var/www/packages
$ cd /var/www/packages
$ rsync -a rsync://archive.ubuntu.com/ubuntu /media/mirror/ubuntu

if you want faster download you can download from multi source.
the complete list is in https://launchpad.net/ubuntu/+archivemirrors
you also can also can combine all means, such as ftp, http and rsync
the following is the size of directory of the mirror
952M    indices/
580K     project/
51G       dists/
0           ubuntu/
             pool/      
             265G    main
             38G    multiverse
             8.6G    restricted
             390G    univers

2- setup web server to host the repository
$ sudo apt-get install apache2

- create a file debrepo.conf in /etc/apache2/sites-enabled with the following content
<VirtualHost *:80>
    ServerName deb.repo
    DocumentRoot  /var/www/packages
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    <Directory  /var/www/packages>
        Options Indexes FollowSymLinks MultiViews
                AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>


- restart the apache2

$ sudo service apache2 restart

3- on client edit the /etc/apt/sources.list to use our own repository as below if your current ubuntu is not trusty change it.
deb http://deb.repo/ubuntu trusty universe
deb http://deb.repo/ubuntu trusty main
deb http://deb.repo/ubuntu trusty multiverse
deb http://deb.repo/ubuntu trusty restricted


4- install vim
$ sudo apt-get update
$ sudo apt-get install vim



Note: we can update the repository monthly by using crond with the command below
$ rsync -a rsync://archive.ubuntu.com/ubuntu /media/mirror/ubuntu

No comments:

Post a Comment