需求:在本地搭载一个更新源作为服务器,这样在局域网内的其他虚拟机就可以通过在服务器端下载软件包,可以节省很多时间
首先要确保要作为服务器的主机能连上网络,下面是具体的配置步骤
1、使用apt-mirror创建Ubuntu Source服务器的本地镜像服务器
sudo apt-get install apt-mirror
2、sudo apt-get install apache2
需要以上两个软件来构建我们的Ubuntu12.04的服务器
3、修改/etc/apt/mirror.list的配置文件为以下情况:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
############# 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 <running host architecture>
# set postmirror_script $var_path/postmirror.sh
# set run_postmirror 0
set
nthreads 20
set
_tilde 0
#
############# end config ##############
deb http:
//debian
.ustc.edu.cn
/ubuntu/
precise main multiverse restricted universe
deb http:
//debian
.ustc.edu.cn
/ubuntu/
precise-backports main multiverse restricted universe
deb http:
//debian
.ustc.edu.cn
/ubuntu/
precise-proposed main multiverse restricted universe
deb http:
//debian
.ustc.edu.cn
/ubuntu/
precise-security main multiverse restricted universe
deb http:
//debian
.ustc.edu.cn
/ubuntu/
precise-updates main multiverse restricted universe
deb-src http:
//debian
.ustc.edu.cn
/ubuntu/
precise main multiverse restricted universe
deb-src http:
//debian
.ustc.edu.cn
/ubuntu/
precise-backports main multiverse restricted universe
deb-src http:
//debian
.ustc.edu.cn
/ubuntu/
precise-proposed main multiverse restricted universe
deb-src http:
//debian
.ustc.edu.cn
/ubuntu/
precise-security main multiverse restricted universe
deb-src http:
//debian
.ustc.edu.cn
/ubuntu/
precise-updates main multiverse restricted universe
deb-i386 http:
//debian
.ustc.edu.cn
/ubuntu/
precise main multiverse restricted universe
deb-i386 http:
//debian
.ustc.edu.cn
/ubuntu/
precise-backports main multiverse restricted universe
deb-i386 http:
//debian
.ustc.edu.cn
/ubuntu/
precise-proposed main multiverse restricted universe
deb-i386 http:
//debian
.ustc.edu.cn
/ubuntu/
precise-security main multiverse restricted universe
deb-i386 http:
//debian
.ustc.edu.cn
/ubuntu/
precise-updates main multiverse restricted universe
|
备注:debian
.ustc.edu.cn为我们使用的中国科技大学的Ubuntu Source服务器作为的我们的源服务器。
deb-i386 http://* 表示下载32位版本的deb软件。
因为之前也修改了/etc/apt/source.list,但是两个配置文件都修改了之后,后续的步骤不能下载成功,所以把source.list又还原成了系统自带的,结果成功了
4、执行 sudo apt-mirror
这会启动20个线程到设置中的地址去下载响应的deb包,这个会运行很长时间,因为要下载的东西很多
执行完成后,/var/spool/apt-mirror目录下就有了所有需要的deb包和相应的配置
我们需要一个web服务器来启动我们本地的ubuntu source服务器,这里选择的是apache2。apache2服务器安装后,默认使用/var/www/目录作为
web的根目录。
5、
cd
/var/www/
ln
/var/spool/apt-mirror/mirror/debian
.ustc.edu.cn
/ubuntu/
-s
在/var/www目录下创建一个Ubuntu超链接,链接到/var/spool/apt-mirror/mirror/debian.ustc.edu.cn/ubuntu/上
6、sudo /etc/init.d/apache2 start/restart/stop/status 命令可以管理apache2服务器。
deb http:
//222
.24.24.175
/ubuntu/
precise main multiverse restricted universe
deb http:
//222
.24.24.175
/ubuntu/
precise-backports main multiverse restricted universe
deb http:
//222
.24.24.175
/ubuntu/
precise-proposed main multiverse restricted universe
deb http:
//222
.24.24.175
/ubuntu/
precise-security main multiverse restricted universe
deb http:
//222
.24.24.175
/ubuntu/
precise-updates main multiverse restricted universe
deb-src http:
//222
.24.24.175
/ubuntu/
precise main multiverse restricted universe
deb-src http:
//222
.24.24.175
/ubuntu/
precise-backports main multiverse restricted universe
deb-src http:
//222
.24.24.175
/ubuntu/
precise-proposed main multiverse restricted universe
deb-src http:
//222
.24.24.175
/ubuntu/
precise-security main multiverse restricted universe
deb-src http:
//222
.24.24.175
/ubuntu/
precise-updates main multiverse restricted universe
debhttp://192.168.1.199/ubuntu/ precise main multiverse restricted universe
debhttp://192.168.1.199/ubuntu/ precise-backports main multiverse restricteduniverse
debhttp://192.168.1.199/ubuntu/ precise-proposed main multiverse restricteduniverse
debhttp://192.168.1.199/ubuntu/ precise-security main multiverse restricteduniverse
debhttp://192.168.1.199/ubuntu/ precise-updates main multiverse restricteduniverse
deb-srchttp://192.168.1.199/ubuntu/ precise main multiverse restricted universe
deb-srchttp://192.168.1.199/ubuntu/ precise-backports main multiverse restricteduniverse
deb-srchttp://192.168.1.199/ubuntu/ precise-proposed main multiverse restricteduniverse
deb-srchttp://192.168.1.199/ubuntu/ precise-security main multiverse restricteduniverse
deb-srchttp://192.168.1.199/ubuntu/ precise-updates main multiverse restricteduniverse
其中,192.168.1.199为服务器计算机的ip地址。