创建ubuntu软件源

缘起:虚拟机需要安装一些文件,但是直接从外网下载比较慢,而且安装iso包中是有这些软件的,所以创建一个ubuntu  apt server 

ubuntu 12.04, 本机192.168.0.124, 虚拟机192.168.0.101

step0.

本机安装apache,apt-get install apache2

step1.

在本机上挂载iso镜像

mount -o loop /media/Work/LinuxDistribution/Ubuntu12.0.4/ubuntu-12.04.2-server-amd64.iso /media/apt/

step2.

将/media/apt目录下的所有文件拷贝到/var/www/ubuntu目录下,修改其权限

cp -R /media/apt/* /var/www/ubuntu/

chown -R www-data.www-data /var/www/ubuntu

step3.

在虚拟机上修改/etc/apt/source.list

添加如下三行:

deb http://192.168.0.124/ubuntu dists/precise/main/binary-i386/
deb http://192.168.0.124/ubuntu dists/precise/restricted/binary-i386/
deb http://192.168.0.124/ubuntu precise main restricted

step4.

在虚拟机上执行apt-get update,并安装需要的软件包

apt-get install build-essential

 

附1:

如何在本机上使用ISO 作文软件更新源

步骤:

step1.

在本机上挂载iso镜像

mount -o loop /media/Work/LinuxDistribution/Ubuntu12.0.4/ubuntu-12.04.2-server-amd64.iso /media/apt/

 step2.

将/etc/apt/source.list保存为另一个文件,使用apt-cdrom命令

mv /etc/apt/source.list /etc/apt/source.list.sav

apt-cdrom -d /media/apt -m add

生成/etc/apt/source.list文件,内容如下

deb cdrom:[Ubuntu-Server 12.04.2 LTS _Precise Pangolin_ - Release amd64 (20130214)]/ dists/precise/main/binary-i386/
deb cdrom:[Ubuntu-Server 12.04.2 LTS _Precise Pangolin_ - Release amd64 (20130214)]/ dists/precise/restricted/binary-i386/
deb cdrom:[Ubuntu-Server 12.04.2 LTS _Precise Pangolin_ - Release amd64 (20130214)]/ precise main restricted

 

step3.

执行apt-get update即可。

 

附2:

如何创建ubuntu本地仓库源 

step1.

安装apt-mirror

apt-get install apt-mirror

会生成一个apt-mirror用户

step2.

修改/etc/apt/mirror.list文件

touch /etc/apt/mirror.list

############# config ##################
#
# set base_path    /var/spool/apt-mirror
#
# if you change the base path you must create the directories below with write privlages
#
# 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 ##############

修改set base_path ,根据需求修改,比如/var/www/apt-mirror

修改set defaultarch为需要安装机器的型号,否则默认和本机相同

例如:对于一个树莓派来说,配置文件如下

root@InnerServer1:~# cat /etc/apt/mirror.list
############# config ##################
#
set base_path /var/www/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 armhf
# set postmirror_script $var_path/postmirror.sh
# set run_postmirror 0
set nthreads 20
set _tilde 0
#
############# end config ##############

deb http://ports.ubuntu.com/ubuntu-ports/ raring main universe
deb http://ppa.launchpad.net/linaro-maintainers/overlay/ubuntu raring main main/debug


clean http://cn.archive.ubuntu.com/ubuntu

 

对于deb的路径,可以从source.list文件中选取

posted @ 2013-11-04 16:23  silence.li  阅读(789)  评论(0编辑  收藏  举报