在使用VPS服务器的过程中,许多用户都遇到过以下两种典型的系统更新问题:一是执行apt update时频繁出现连接报错,导致无法正常获取软件列表;二是由于系统默认使用海外官方源,在国内网络环境下更新速度极为缓慢,严重影响部署和维护效率。
针对这两种情况,一个简单而有效的解决方案是为系统更换为国内的镜像源。本文将以常用的Ubuntu系统为例,演示如何将默认的官方源替换为阿里云镜像源,从而解决更新失败与速度慢的问题。
第一、备份默认源
cp /etc/apt/sources.list /etc/apt/sources_init.list
第二、更换源通道
vi /etc/apt/sources.list
这里我们打开编辑器,然后将里面内容全部更换成下面内容。
deb http://mirrors.aliyum.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyum.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyum.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyum.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyum.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyum.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyum.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyum.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyum.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyum.com/ubuntu/ trusty-backports main restricted universe multiverse
第三、更新软件和源
apt-get update && upgrade
这里我们就可以使用最新系统进行安装软件。PS:如果我们需要使用其他源,这里贴上163的源,我们有需要也可以使用。
deb http://mirrors.163.com/ubuntu/ wily main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ wily-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ wily-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ wily-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ wily-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ wily main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ wily-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ wily-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ wily-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ wily-backports main restricted universe multiverse


评论