感謝您的閱讀,本文由 楊斌的博客 版權(quán)所有。
如若轉(zhuǎn)載,請(qǐng)注明出處:楊斌的博客(https://y0ngb1n.github.io/a/how-to-install-ubuntu-server-18-04-lts.html?utm_source=jianshu)
前言
由于鴻哥大學(xué)遺留下來一部塵封的臺(tái)式主機(jī),放著積灰還不如拿來給我折騰,讓它能發(fā)光發(fā)熱。所以,經(jīng)過鴻哥同意后,我決定將系統(tǒng)換成 Ubuntu 18.04.2 LTS (Bionic Beaver) 的 Server 版本,搭建家用兼顧學(xué)習(xí)和娛樂的環(huán)境,主要用于開發(fā)學(xué)習(xí)(瞎折騰)的服務(wù)器使用 :facepunch:。
將用來搭建我的 Home Lab,運(yùn)行一些包括但不僅限于以下的服務(wù):
| 服務(wù) | 簡(jiǎn)介 |
|---|---|
| nginx-proxy | 基于 Docker 的自動(dòng)化網(wǎng)關(guān) |
| Pi-hole | 過濾家中廣告 |
| GitLab | 私人代碼倉庫 |
| Jenkins | 持續(xù)集成引擎 |
| Bitwarden | 私人密碼管家 |
| ... | ... |
更多的服務(wù)后續(xù)會(huì)在「y0ngb1n/dockerized」進(jìn)行維護(hù),歡迎 Star :star2:。
獲取 Ubuntu 系統(tǒng)
可以使用下面任一源進(jìn)行獲取 Ubuntu 18.04.2 LTS (Bionic Beaver) 系統(tǒng)鏡像:
| 來源 | 站點(diǎn) |
|---|---|
| Ubuntu 官網(wǎng) | http://releases.ubuntu.com/18.04/ |
| 阿里巴巴開源鏡像站 | https://mirrors.aliyun.com/ubuntu-releases/18.04/ |
| 清華大學(xué)開源軟件鏡像站 | https://mirrors.tuna.tsinghua.edu.cn/ubuntu-releases/18.04/ |
當(dāng)前我要下載的文件名為 ubuntu-18.04.2-live-server-amd64.iso,下載地址為 https://mirrors.aliyun.com/ubuntu-releases/18.04/ubuntu-18.04.2-live-server-amd64.iso,使用阿里巴巴開源鏡像站的源,文件大小為 834.00 MB。
安裝 Ubuntu 系統(tǒng)
安裝系統(tǒng)前,先要準(zhǔn)備一個(gè)容量大于 4G 的 U 盤、一款趁手的鏡像刻錄工具(我選 Etcher)。
Step 1:獲取 Etcher
Flash OS images to SD cards & USB drives, safely and easily.
Etcher 是一款開源的快速刻錄軟件,用它可以快速制作 U 盤鏡像工具。它簡(jiǎn)單到只有一個(gè)高顏值的界面,它能夠幫助你將系統(tǒng)鏡像文件(如 .iso, .img, .dmg, .zip 等格式)快速燒錄進(jìn) USB 設(shè)備(U 盤)或者 SD 卡中。這可下載 Etcher 的最新版本

界面簡(jiǎn)潔,操作簡(jiǎn)單,分三步走:
- 選擇鏡像文件
- 選擇磁盤
- 開始燒錄
Step 2:制作系統(tǒng)啟動(dòng)盤
先將 U 盤連接上電腦,然后打開 Etcher,并選擇剛下載好的系統(tǒng)鏡像和 U 盤,然后點(diǎn)擊 Flash! 按鈕,剩下的就留給 Etcher 幫你完成就好了。
Step 3:刷入 Ubuntu 系統(tǒng)
先將要刷入系統(tǒng)的主機(jī)斷電,并將 U 盤、鍵盤、顯示器連接上。通電后進(jìn)行開機(jī),此時(shí)連按 Escape, F2, F10, F12 或者留意屏幕上的提示(此處不同機(jī)子不一樣,具體可自行 Google),我的是華碩的主板,開機(jī)時(shí)提示我可以點(diǎn) F2 或 DEL 鍵進(jìn)行 BIOS 系統(tǒng),主要是設(shè)置我們的 U 盤作為第一啟動(dòng)盤,優(yōu)先加載 U 盤,這樣我們就能刷系統(tǒng)了。
成功進(jìn)行 U 盤后可以參考由 Ubuntu 提供的安裝指南「Install Ubuntu Server」進(jìn)行安裝操作了。在設(shè)置鏡像一步時(shí)你可使用阿里云的公共鏡像服務(wù),輸入 http://mirrors.aliyun.com/ubuntu/ 即可,這樣可加速你的安裝過程,否則會(huì)默認(rèn)走官方源。
最后就是等待安裝完畢了!:clap: 對(duì),等就行了。
Step 4:登入系統(tǒng)
$ ssh yangbin@192.168.31.188
yangbin@ubuntu:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.2 LTS
Release: 18.04
Codename: bionic
到此就大功告成了!:dog:
配置系統(tǒng)的基礎(chǔ)環(huán)境
安裝完系統(tǒng)后,來做一些簡(jiǎn)單的配置。
配置軟件源
推薦使用阿里云的源,先創(chuàng)建自己的配置文件,比如:
/etc/apt/sources.list.d/aliyun.list
編輯內(nèi)容如下:
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
然后執(zhí)行:
sudo apt-get update
即可。
配置時(shí)區(qū)
不要忘記配置系統(tǒng)時(shí)區(qū),尤其是現(xiàn)在流行將系統(tǒng)時(shí)區(qū)配置掛載到容器中。
$ dpkg-reconfigure tzdata #使用命令行交互界面修改
Current default time zone: 'Asia/Shanghai'
Local time is now: Fri May 3 20:59:14 CST 2019.
Universal Time is now: Fri May 3 12:59:14 UTC 2019.
安裝容器環(huán)境
一鍵安裝 Docker
使用阿里云加速安裝 Docker:
curl -fsSL get.docker.com -o get-docker.sh && \
sudo sh get-docker.sh --mirror Aliyun
啟動(dòng) Docker CE
sudo systemctl enable docker && \
sudo systemctl start docker
一鍵安裝 Compose
Compose 既然是一個(gè) Python 應(yīng)用,自然也可以直接用容器來執(zhí)行它:
export DOCKER_COMPOSE_VERSION=1.24.0
curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/run.sh > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
配置容器鏡像源
mkdir -p /etc/docker && touch /etc/docker/daemon.json
cat <<EOF > /etc/docker/daemon.json
{
"registry-mirrors": [
"https://registry.docker-cn.com"
]
}
EOF
sudo systemctl start docker
更多配置可參考「Ubuntu 18.04 基礎(chǔ)系統(tǒng)配置」解鎖更多姿勢(shì)。
參考鏈接
- https://tutorials.ubuntu.com/tutorial/tutorial-install-ubuntu-server
- https://www.qingsword.com/qing/1258.html
- https://www.wikihow.com/Install-Ubuntu-Server
- https://mk-dir.com/installing-ubuntu-server-old-pc/
- https://www.ceos3c.com/open-source/install-ubuntu-server-18-04-lts/
- https://www.youtube.com/watch?v=w5W_48vyC6U
- https://www.youtube.com/watch?v=vt5Lu_ltPkU
- https://soulteary.com/2019/04/06/configure-ubuntu-18-04.html
- https://medium.com/@killyourfm/the-beginners-guide-to-installing-ubuntu-linux-18-04-lts-6c8230036d84
- https://mirrors.ustc.edu.cn/help/dockerhub.html