本篇主要记录 Ubuntu 安装软件的过程

开启root账号ssh

1
2
3
4
5
6
7
8
9
10
su root
# 写入证书
cat ~/.ssh/id_rsa.pub | tee /root/.ssh/authorized_keys
chmod 600 /root/.ssh/authorized_keys
# 启用root登录, 禁用密码登录, 启用证书登录
sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
sed -i 's/#PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config
sed -i 's/#PubkeyAuthentication yes/PubkeyAuthentication yes/' /etc/ssh/sshd_config
# 重启ssh
systemctl restart ssh

ssh-keygen -R example.com 清除ssh指纹

更换源及升级包

升级包

1
2
# 更新所有软件
apt update && apt upgrade -y

更改语言

1
2
3
4
apt install fonts-wqy-zenhei && fc-cache
sed -i 's/^# zh_CN.UTF-8 UTF-8/zh_CN.UTF-8 UTF-8/' /etc/locale.gen
locale-gen
echo 'LANG=zh_CN.UTF-8' | tee /etc/default/locale

网络配置

使用nmtui工具配置WIFI

1
apt install network-manager

安装ShellClash

阅读官方文档

1
export url='https://fastly.jsdelivr.net/gh/juewuy/ShellCrash@master' && wget -q --no-check-certificate -O /tmp/install.sh $url/install.sh  && bash /tmp/install.sh && source /etc/profile &> /dev/null

安装Docker及常用镜像

1
curl -sSL https://get.docker.com | sh   # 脚本安装
1
nano /etc/docker/daemon.json            # 修改配置文件
1
2
3
4
{
"data-root": "/var/lib/docker",
"dns": ["114.114.114.114", "8.8.8.8"]
}

配置 Docker Pull 代理

1
2
# 修改服务配置文件
vi /etc/systemd/system/multi-user.target.wants/docker.service
1
2
3
Environment=HTTP_PROXY=http://127.0.0.1:7890
Environment=HTTPS_PROXY=http://127.0.0.1:7890
Environment=NO_PROXY=localhost,127.0.0.1
1
2
3
# 重启服务
systemctl daemon-reload
systemctl restart docker

进入容器内部
docker exec -it 容器ID /bin/sh

安装Portainer

安装Portainer社区版

1
2
3
4
5
6
7
docker run -d \
-p 9000:9000 \
--name=Portainer \
--restart=always \
-v /var/run/docker.sock:/var/run/docker.sock
-v /home/Docker/Portainer:/data
portainer/portainer-ce

安装PortainerAgent

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
export EDGE_ID=""
export EDGE_KEY=""

docker run -d \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /var/lib/docker/volumes:/var/lib/docker/volumes \
-v /:/host \
-v Portainer:/data \
--restart always \
-e EDGE=1 \
-e EDGE_ID="$EDGE_ID" \
-e EDGE_KEY="$EDGE_KEY" \
-e EDGE_INSECURE_POLL=1 \
--name PortainerEdgeAgent \
portainer/agent
1
2
3
4
5
6
7
8
9
# 创建网络, 以便后续使用
network_name="network"

if docker network ls | grep -q "network"; then
echo "网络已存在"
else
docker network create --driver bridge --gateway=172.18.0.1 --subnet=172.18.0.0/24 network
echo "网络创建成功"
fi

AList

仅安装 AList

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
services:  
alist:
image: 'xhofe/alist-aria2'
container_name: AList
volumes:
- 'vol_1:/opt/alist/data'
- '/etc/docker/containers/alist/config.json:/opt/alist/data/config.json'
environment:
- 'PUID=0'
- 'PGID=0'
- 'TZ=Asia/Shanghai'
ports:
- '5244:5244'
restart: unless-stopped
networks:
- persist

networks:
persist:
external: true
name: network

volumes:
vol_1:
name: AList

包括 QbitTorrent 和 Aria2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
services:  
qbittorrent:
image: 'linuxserver/qbittorrent'
container_name: Qbittorrent
environment:
- 'PUID=0'
- 'PGID=0'
- 'TZ=Asia/Shanghai'
- 'TORRENTING_PORT=6881'
- 'WEBUI_PORT=6879'
volumes:
- 'vol_2:/config'
- 'vol_downloads:/downloads'
ports:
- '5244:5244'
- '6800:6800'
- '6880:6880'
- '6879:6879'
- '6881:6881'
- '6881:6881/udp'
restart: unless-stopped
networks:
- persist

alist:
image: 'xhofe/alist-aria2'
container_name: AList
volumes:
- 'vol_1:/opt/alist/data'
- 'vol_downloads:/opt/alist/data/temp/qbittorrent'
- '/mnt/share:/mnt/share'
- '/etc/docker/containers/alist/config.json:/opt/alist/data/config.json'
environment:
- 'PUID=0'
- 'PGID=0'
- 'TZ=Asia/Shanghai'
restart: unless-stopped
network_mode: "service:qbittorrent"

AriaNg:
image: 'p3terx/ariang'
container_name: AriaNg
restart: unless-stopped
network_mode: "service:qbittorrent"

networks:
persist:
external: true
name: network

volumes:
vol_1:
name: AList
vol_2:
name: Qbittorrent
vol_downloads:
name: Downloads-Qbittorrent

关系型数据库

MySQL

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
services:
MySQL:
image: 'mysql'
container_name: MySQL
restart: always
ports:
- '3306:3306'
volumes:
- 'vol_1:/var/lib/mysql'
environment:
- 'MYSQL_ROOT_PASSWORD='
- 'TZ=Asia/Shanghai'
networks:
- persist

networks:
persist:
external: true
name: network

volumes:
vol_1:
name: MySQL

MariaDB

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
services:
MariaDB:
image: mariadb
container_name: MariaDB
restart: always
ports:
- '3307:3306'
volumes:
- 'vol_1:/var/lib/mysql'
environment:
- 'MARIADB_ROOT_PASSWORD='
- 'TZ=Asia/Shanghai'
networks:
- persist

networks:
persist:
external: true
name: network

volumes:
vol_1:
external: true
name: MariaDB

MongoDB

在不支持AVX指令集的CPU上必须使用4.4.18版本, 不支持5.0+版本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
services:
MongoDB:
image: mongo:4.4.18
container_name: MongoDB
restart: always
ports:
- '27017:27017'
volumes:
- 'vol_1:/data'
environment:
- 'MONGO_INITDB_ROOT_USERNAME=root'
- 'MONGO_INITDB_ROOT_PASSWORD='
networks:
- persist

networks:
persist:
external: true
name: network

volumes:
vol_1:
external: true
name: MongoDB

HomeAssistant

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
services:
HomeAssistant:
image: homeassistant/home-assistant
container_name: HomeAssistant
restart: always
ports:
- '8500:8123'
volumes:
- 'vol_1:/config'
networks:
- persist

networks:
persist:
external: true
name: network

volumes:
vol_1:
external: true
name: HomeAssistant

安装常用语言

安装Go

1
2
3
4
5
6
7
8
GO_VERSION="1.23.2"
DEVICE="linux-amd64" # linux-amd64 / linux-arm64
GO_URL="https://golang.google.cn/dl/go$GO_VERSION.$DEVICE.tar.gz"
wget -O go.tar.gz $GO_URL
sudo tar -C /usr/local -xzf go.tar.gz
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc
source ~/.bashrc
go version

安装NodeJs

1
2
3
4
5
6
7
8
NODE_VERSION="20.18.0"
DEVICE="linux-x64" # linux-x64 / linux-arm64
NODE_URL="https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-$DEVICE.tar.xz"
wget -O node.tar.xz $NODE_URL
sudo tar -C /usr/local --strip-components 1 -xf node.tar.xz
echo 'export PATH=$PATH:/usr/local/bin' >> ~/.bashrc
source ~/.bashrc
node -v && npm -v