國內如騰訊云、阿里云、華為云這些大型的云主機商家一般不存在此問題,但是一些比較小眾的國內云主機經常會遇到的問題,如下載更新軟件速度慢。如果預裝系統沒有根據位置選擇合適軟件源鏡像,建議手動修改 Debian 軟件源鏡像以加快速度。本文將指導新手用戶更換軟件源,希望對用戶有所幫助。
國內 Debian 軟件源鏡像
列出幾個常用國內 Debian 軟件源鏡像。點此可查看完整鏡像節點。
| 鏡像節點 | 鏡像地址 |
|---|---|
| Debian | http://ftp.cn.debian.org/debian/ |
| 阿里云 | http://mirrors.aliyun.com/debian/ |
| 華為云 | http://mirrors.aliyun.com/debian/ |
| 網易 | http://mirrors.163.com/debian/ |
| 清華大學 | http://mirrors.tuna.tsinghua.edu.cn/debian/ |
| 中國科大 | http://mirrors.ustc.edu.cn/debian/ |
| 蘭州大學 | http://mirror.lzu.edu.cn/debian/ |
更換 Debian 軟件源鏡像
在操作前,先重命名備份軟件源配置文件,以便在需要時可以還原。
mv /etc/apt/sources.list /etc/apt/sources.list.bak
創建新的配置文件。
vi /etc/apt/sources.list
內容如下(通常只需按需修改其中發行版代號和鏡像地址,詳細查看后面備注介紹)。
deb http://ftp.cn.debian.org/debian/ buster main contrib non-free deb-src http://ftp.cn.debian.org/debian/ buster main contrib non-free deb http://ftp.cn.debian.org/debian-security/ buster/updates main contrib non-free deb-src http://ftp.cn.debian.org/debian-security/ buster/updates main contrib non-free deb http://ftp.cn.debian.org/debian/ buster-updates main contrib non-free deb-src http://ftp.cn.debian.org/debian/ buster-updates main contrib non-free deb http://ftp.cn.debian.org/debian/ buster-backports main contrib non-free deb-src http://ftp.cn.debian.org/debian/ buster-backports main contrib non-free
逐個介紹配置內容里的參數含義:
- deb:二進制軟件包;
- deb-src:源代碼軟件包;
- 網址:軟件包鏡像地址;
- 發行版代號:適用對應發行版的軟件包,可用
lsb_release -c命令查詢代號名稱; - 發行版代號跟隨參數:軟件包類型(
xxxxx/updates安全錯誤更新,xxxxx-updates?普通維護更新,xxxxx-backports向后移植軟件包,將較新軟件補丁移植到舊版軟件上); - main:遵循 DFSG 標準的自由軟件;
- contrib:遵循 DFSG 標準的自由軟件,但存在?non-free 依賴;
- non-free:不符合 DFSG 標準的軟件;
更新配置文件后重建軟件包索引生效。
apt-get update
如果你用的是 https 軟件源鏡像地址,那么需要確保已安裝下面兩個軟件。
apt-get install apt-transport-https ca-certificates






















