apt-mirrorをたてる
モチベーション
- ローカルでPXEブートしたい.外にはつなぎたくない.でもapt-mirror....
- そうだ、自前でローカルにapt-mirrorを立てよう
install
$ sudo apt-get install apt-mirror
configuration
面倒なので全部ミラーした. 12.04と14.04の両方のミラーが欲しいので,preciseとtrustyの2種類を作成する. deb-i386の行はNot Foundが出るのが気に入らないので追加した. PXEブート等を行う際にはdebian-installerのミラーも必要なので注意.
$ sudo vi /etc/apt/mirror.list
############# config ################## # set base_path /var/spool/apt-mirror # 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 amd64 set postmirror_script $var_path/postmirror.sh set run_postmirror 1 set nthreads 4 set _tilde 0 # ############# end config ############## # 12.04(precise) deb http://jp.archive.ubuntu.com/ubuntu precise main restricted universe multiverse deb http://jp.archive.ubuntu.com/ubuntu precise-security main restricted universe multiverse deb http://jp.archive.ubuntu.com/ubuntu precise-updates main restricted universe multiverse deb http://jp.archive.ubuntu.com/ubuntu precise-proposed main restricted universe multiverse deb http://jp.archive.ubuntu.com/ubuntu precise-backports main restricted universe multiverse # debian installer here deb http://jp.archive.ubuntu.com/ubuntu precise main/debian-installer restricted/debian-installer deb-i386 http://jp.archive.ubuntu.com/ubuntu precise main restricted universe multiverse deb-i386 http://jp.archive.ubuntu.com/ubuntu precise-security main restricted universe multiverse deb-i386 http://jp.archive.ubuntu.com/ubuntu precise-updates main restricted universe multiverse deb-i386 http://jp.archive.ubuntu.com/ubuntu precise-proposed main restricted universe multiverse deb-i386 http://jp.archive.ubuntu.com/ubuntu precise-backports main restricted universe multiverse # debian installer here deb-i386 http://jp.archive.ubuntu.com/ubuntu precise main/debian-installer restricted/debian-installer deb-src http://jp.archive.ubuntu.com/ubuntu precise main restricted universe multiverse deb-src http://jp.archive.ubuntu.com/ubuntu precise-security main restricted universe multiverse deb-src http://jp.archive.ubuntu.com/ubuntu precise-updates main restricted universe multiverse deb-src http://jp.archive.ubuntu.com/ubuntu precise-proposed main restricted universe multiverse deb-src http://jp.archive.ubuntu.com/ubuntu precise-backports main restricted universe multiverse # 14.04(trusty) deb http://jp.archive.ubuntu.com/ubuntu trusty main restricted universe multiverse deb http://jp.archive.ubuntu.com/ubuntu trusty-security main restricted universe multiverse deb http://jp.archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse deb http://jp.archive.ubuntu.com/ubuntu trusty-proposed main restricted universe multiverse deb http://jp.archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse # debian installer here deb http://jp.archive.ubuntu.com/ubuntu trusty main/debian-installer restricted/debian-installer deb-i386 http://jp.archive.ubuntu.com/ubuntu trusty main restricted universe multiverse deb-i386 http://jp.archive.ubuntu.com/ubuntu trusty-security main restricted universe multiverse deb-i386 http://jp.archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse deb-i386 http://jp.archive.ubuntu.com/ubuntu trusty-proposed main restricted universe multiverse deb-i386 http://jp.archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse # debian installer here deb-i386 http://jp.archive.ubuntu.com/ubuntu trusty main/debian-installer restricted/debian-installer deb-src http://jp.archive.ubuntu.com/ubuntu trusty main restricted universe multiverse deb-src http://jp.archive.ubuntu.com/ubuntu trusty-security main restricted universe multiverse deb-src http://jp.archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse deb-src http://jp.archive.ubuntu.com/ubuntu trusty-proposed main restricted universe multiverse deb-src http://jp.archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse clean http://jp.archive.ubuntu.com/ubuntu
apt-mirror作成
12.04と14.04,さらに共にamd64とi386を用意するので必要なストレージ容量は250GB以上.
でも偉い人が言ってた.ストレージなんてタダみたいなもんだと.
終了に数時間かかります.
$ sudo apt-mirror
自動更新
最後の行のコメントアウトを外しただけ.毎朝4時に更新するらしい.
$ sudo vi /etc/cron.d/apt-mirror
# # Regular cron jobs for the apt-mirror package # 0 4 * * * apt-mirror /usr/bin/apt-mirror > /var/spool/apt-mirror/var\ /cron.log
公開
- Install apatche2
$ sudo apt-get install apache2
- httpの設定
$ sudo ln -s /var/spool/apt-mirror/mirror/jp.archive.ubuntu.com/ubuntu /var/www/ubuntu
Apacheが2.4系だった場合
- Ubuntu13.10からapt-getで入るApacheが2.4系になり,上記の操作のみでは公開できない.
- Apacheは詳しくないので,Apache2.2系の設定のそれっぽい箇所を2.4のそれっぽいところにコピペしたら動作した.このため,アクセス制御の書式が2.2に準じており,美しくない.あとで治す.
セキュリティ的に危ないので,外部には公開しないように注意.
/etc/apache2/sites-enabled/000-default.conf を修正
- DocumentRoot /var/www/html
+ DocumentRoot /var/www + <Directory /> + Options FollowSymLinks + AllowOverride None + </Directory> + <Directory /var/www/> + Options Indexes FollowSymLinks MultiViews + AllowOverride None + Order allow,deny + allow from all + </Directory>
終わり.