赞
踩
如果存在无法连接公网的情况并且有多台服务器需要安装多个软件,可以使用mirror做一个本地仓库,使其其他机器可以通过本地仓库下载需要的软件,本地仓库需要使用Apache2,具体配置可以参考下面的Apache2。
sudo apt-get install apt-mirror #安装mirror
sudo vim /etc/apt/mirror.list #修改mirror配置文件
按照如下的配置修改地址,软件园下载的地址为阿里的,此地址不包含src源码文件
############# config ################## # 下载文件包的目录,默认即可 # set base_path /var/spool/apt-mirror # 镜像文件下载地址 # set mirror_path $base_path/mirror # 临时索引下载文件目录,也就是存放软件仓库的dists目录下的文件(默认即可) # set skel_path $base_path/skel # 配置日志(默认即可) # set var_path $base_path/var # clean脚本位置 # set cleanscript $var_path/clean.sh # 架构配置,i386/amd64,默认的话会下载跟本机相同的架构的源 # 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://archive.ubuntu.com/ubuntu xenial main restricted universe multiverse #deb http://archive.ubuntu.com/ubuntu xenial-security main restricted universe multiverse #deb http://archive.ubuntu.com/ubuntu xenial-updates main restricted universe multiverse #deb http://archive.ubuntu.com/ubuntu xenial-proposed main restricted universe multiverse #deb http://archive.ubuntu.com/ubuntu xenial-backports main restricted universe multiverse #deb-src http://archive.ubuntu.com/ubuntu xenial main restricted universe multiverse #deb-src http://archive.ubuntu.com/ubuntu xenial-security main restricted universe multiverse #deb-src http://archive.ubuntu.com/ubuntu xenial-updates main restricted universe multiverse #deb-src http://archive.ubuntu.com/ubuntu xenial-proposed main restricted universe multiverse #deb-src http://archive.ubuntu.com/ubuntu xenial-backports main restricted universe multiverse #clean http://archive.ubuntu.com/ubuntu # Aliyun(这里没有添加deb-src的源) deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse clean http://mirrors.aliyun.com/ubuntu
sudo apt-mirror
注:执行完成后会下载mirrors.aliyun.com的包到/var/spool/apt-mirror/mirror/mirrors.aliyun.com/ubuntu的默认目录上。
sudo apt-get instal
如果Apache2安装完成,可以通过浏览器访问IP+port形式访问(默认的port是80),如果安装成功会出现Apache2的页面
由于Apache2的默认网页文件目录位于/var/www/html,因此,可以需要做个软链接,这样就可以直接访问了,无需将其直接导入该目录
sudo ln -s /var/spool/apt-mirror/mirror/mirrors.aliyun.com/ubuntu /var/www/html/Ubuntu
如果想要删除软连接的话,执行sudo rm -rf /var/www/html/Ubuntu
即可
修改/etc/apt/source.list配置,将之前的访问地址注释,新增自己的地址
# Local Source ip和port是自己本机的,其中端口默认为80
deb [arch=amd64] http://ip:port/ubuntu/ trusty main restricted universe multiverse
deb [arch=amd64] http://ip:port/ubuntu/ trusty-security main restricted universe multiverse
deb [arch=amd64] http://ip:port/ubuntu/ trusty-updates main restricted universe multiverse
deb [arch=amd64] http://ip:port/ubuntu/ trusty-proposed main restricted universe multiverse
deb [arch=amd64] http://ip:port/ubuntu/ trusty-backports main restricted universe multiverse
sudo apt-get update # 或者 sudo apt update
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。