配置Linux本地源镜像
今天看到同事做了一个公司本地的apache镜像源,感觉好叼的样子。然后就自己上网找些资料,尝试自己搭建一套出来。然后就有了这篇博文。。。
声明:本文中充满了浓浓的技术嫉妒的心理,阅读需谨慎。
本文以 [ubuntu16.4LTS 64位] 为例子进行配置,其他系统大同小异,如果在配置中遇到了奇葩问题,请留言讨论或自行百度。
第一步:找到源配置文件
在ubuntu下,源文件的位置为: /etc/apt/source.list 。使用vim或者nano等编辑器,以管理员身份打开即可观赏代码。
第二部:找一个好用的镜像地址列表
我找的是阿里的一个镜像站,其他的也有很多,我觉着阿里至少在五年之内不会倒闭,所以就选它了。
首先将原文件备份:
cp ./source.list ./source.list.bak
然后开始修改 source.list 文件,将文件中所有的代码全部注释掉,使用 # 符号实现。然后将以下代码拷贝到文件中去:
# 源码
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse # 测试版源
deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse # 源码(src)
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse # 测试版源
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse # Canonical 合作伙伴和附加
deb http://archive.canonical.com/ubuntu/ xenial partner
deb http://extras.ubuntu.com/ubuntu/ xenial main
保存退出。至此,我们就将原来的`蜗牛`版的源替换成了`急速`版的源了。执行下update试试,是不是发现速度快了很多?
第三步:执行完update后,我们来安装一个工具先
sudo apt-get install -y apt-mirror
这个工具是用来拷贝配置本地源的。安装完后来配置此工具:
vim /etc/apt/mirrors.list set nthreads 20
set _tilde 0
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
现在都配置好了,开始执行下载操作:
apt-mirror
NOTE:大约80G,先看看硬盘在决定要不要继续吧。速度么,再快能怎么快呢?毕竟80G。
第四步:配置本机源
假设你已经下载完了,无论是下一半玩技术还是真的等了一夜下载,无所谓,现在开始对本地源进行配置了。
下载的源路径大概再这里 /var/spool/apt-mirror/mirror/mirrors.aliyun.com/ubuntu
执行以下代码完成配置:
# 编辑source.list文件
vim /etc/apt/sources.list deb file:///var/spool/apt-mirror/mirror/mirrors.aliyun.com/ubuntu trusty main restricted universe multiverse
deb file:///var/spool/apt-mirror/mirror/mirrors.aliyun.com/ubuntu trusty-security main restricted universe multiverse
deb file:///var/spool/apt-mirror/mirror/mirrors.aliyun.com/ubuntu trusty-updates main restricted universe multiverse
deb file:///var/spool/apt-mirror/mirror/mirrors.aliyun.com/ubuntu trusty-proposed main restricted universe multiverse
deb file:///var/spool/apt-mirror/mirror/mirrors.aliyun.com/ubuntu trusty-backports main restricted universe multiverse
至此,本地源配置完成,恭喜恭喜。
第五步:将源开放
如果自己一个人用一个80G的源,有点自私,也有点浪费资源了。互联网本着开放自由共享的原则才发展到现在的境地,为何不把本地的80G源开放共享下呢?同事们也会很感激你的。
首先,要安装一个工具:
sudo apt-get install apache2
然后将镜像文件链接到 apache2 的根目录下(大概是这个目录 /var/www/html/):
ln -s /var/spool/apt-mirror/mirror/mirrors.aliyun.com/ubuntu /var/www/html/ubuntu
此时,本地源的开放已经完成了。别人要使用你的源,则需要稍微进行下配置即可:
# 在别人家的机器上操作
vim /etc/apt/sources.list # 添加源配置,x.x.x.x 表示你的机器的IP地址
deb http://x.x.x.x/ubuntu trusty main restricted universe multiverse
deb http://x.x.x.x/ubuntu trusty-security main restricted universe multiverse
deb http://x.x.x.x/ubuntu trusty-updates main restricted universe multiverse
deb http://x.x.x.x/ubuntu trusty-proposed main restricted universe multiverse
deb http://x.x.x.x/ubuntu trusty-backports main restricted universe multiverse
好了,这下就彻底配置完成了。
配置Linux本地源镜像的更多相关文章
- Centos配置yum本地源最简单的办法
有关centos配置yum本地源的方法 一.前提 先连接镜像 然后在命令行输入如下命令 mount /dev/sr0 /mnt cd /etc/yum.repos.d/ ls 之后会看到如下的界面 二 ...
- redhat 7 配置yum本地源
http://www.unixarena.com/2015/04/how-to-create-the-yum-repository-on-rhel-7.html 1. 在虚拟机上挂上cd 2. m ...
- Oracle linux6.1配置yum本地源
一.准备工作1. Linux安装盘插入光驱2. 挂载光驱 [root@localhost ~]# mount /dev/cdrom /mnt/ mount: block device /dev/sr0 ...
- 配置rpm本地源及局域网环境下使用
LInux个人开发过程中可以直接连到公网,所以想要安装各种软件时直接安装即可,但工作环境往往很让人头疼. 如果应用场景是没法链接外网的,公司内部绝大多数情况下是在自己的局域网下玩,这时候想装个软件是相 ...
- linux修改源镜像地址
1.1 CentOS修改yum源镜像地址为:mirrors.163.com (也可以改为阿里云镜像) 1.首先备份系统自带yum源配置文件/etc/yum.repos.d/CentOS-Base.re ...
- Linux下挂载iso文件和配置yum本地源
Linux的版本: [root@pbn ~]# head -n 1 /etc/issueRed Hat Enterprise Linux Server release 6.1 (Santiago) 1 ...
- centos7配置yum本地源(iso镜像)及局域网使用
2.测试环境: 服务器1:44.135.8.19(yum源) 服务器2:44.135.8.1(局域网机器) 系统:centos7.4 上传iso镜像到服务器,并挂载iso镜像 mount -t iso ...
- 无网络下,配置yum本地源
1. 新建一个没有iso镜像文件的虚拟机: 2. 本地上传一个镜像文件(CentOS7的镜像),到虚拟机已创建的目录: 例如:上传一个镜像文件CentOS-7-x86_64-Everything-17 ...
- RHEL 5.7 Yum配置本地源[Errno 2] No such file or directory
在Red Hat Enterprise Linux Server release 5.7 上配置YUM本地源时,遇到了"Errno 5] OSError: [Errno 2] No such ...
随机推荐
- Oracle EBS Standard Package Function Add User & Resp
Oracle EBS Standard Package Function Add User & Resp. fnd_user_pkg.CreateUser; fnd_user_pkg.AddR ...
- delphi 10.1 berlin datasnap提交clientdataset.delta报:invalid variant type conversion(类型转换错误)问题的解决
delphi 10.1 berlin datasnap提交clientdataset.delta报:invalid variant type conversion(类型转换错误)问题的解决,需要打这个 ...
- task3:词频统计
相关的类: java.util.regex.Pattern static Pattern compile(String regex) //编译模式 static Pattern compile(Str ...
- [Elixir002]节点启动后自动连接其它节点
问题: 如何指定一个节点在启动后自动连接到别的节点上? 这个我们要使用到sys.config,这是erlang的配置文件,这个文件一般都是$ROOT/releases/Vsn下 1. 首先我们要先启动 ...
- [Erlang29]进程收到不是期望的消息时怎么办?
最近在项目中升级了第三方库,导致本应用gen_server中A进程中: handle_info({add,X},Sum) -> {noreply,Sum+X}; 结果这么简单的一个工作居然不工作 ...
- java随笔——HashMap与红黑树
前言: hashmap是一种很常用的数据结构,其使用方便快捷,接下来笔者将给大家深入解析这个数据结构,让大家能在用的时候知其然,也知其所以然. 一.Map 首先,从最基本的讲起,我们先来认识一下map ...
- 重新使用Eclipse建立安卓工程遇到的问题
很早之前用过Eclipse建立安卓工程,很久没用了,最近打算用Eclipse开发安卓程序,我是用谷歌提供的Eclipse集成环境建立的安卓工程,发现有了一些变化,而且遇到一点问题,这几天不断学习,终于 ...
- MySql数据库备份的几种方式
mysqldump工具备份 备份整个数据库 $> mysqldump -u root -h host -p dbname > backdb.sql 备份数据库中的某个表 $> mys ...
- 【BZOJ1956】[Ahoi2005]SHUFFLE 洗牌
题目描述: 这道题,我们首先一眼瞪出来一个规律:对于一个位置为i的牌,在1次洗牌后,他的位置处于(i*2)%(n+1) 的位置 那么,显然的,对于M次洗牌 我们只需要求出2的m次方,这个我们采用快速幂 ...
- 点击文字,把input type="radio"也选中
本文原文地址:https://my.oschina.net/jack088/blog/469815 1. <label> <input type="radio" ...