安装 Ubuntu 22.04 (LTS), Webmin, Nginx, MariaDB, PHP8.1-FPM,Perl-Fastcgi 到 DigitalOcean 的 VPS
在第一部分,DavidYin 介绍了如何在 DigitalOcean 创建新 VPS,选择基本的 Ubuntu 22.04 LTS的系统。
下面是介绍如何安装 Webmin 这个主机控制面板和 SSH 的安全设置。这非常重要,安全性的事情,如何小心都不为过。
第二部分
最初的安全更新
首先,我使用的是 Putty,这是一个 SSH 工具,先用 putty 登录 VPS,IP 地址可以登录到 DigitalOcean 后台看到,用户名就是 root,密码是自己设置的那个密码。
登录到 VPS 之后,执行 apt update
,查询软件库的信息。
root@fig:~# apt update
Hit:1 https://repos.insights.digitalocean.com/apt/do-agent main InRelease
Hit:2 https://repos-droplet.digitalocean.com/apt/droplet-agent main InRelease
Get:3 http://mirrors.digitalocean.com/ubuntu jammy InRelease [270 kB]
Get:4 http://security.ubuntu.com/ubuntu jammy-security InRelease [110 kB]
Hit:5 http://mirrors.digitalocean.com/ubuntu jammy-updates InRelease
Hit:6 http://mirrors.digitalocean.com/ubuntu jammy-backports InRelease
Fetched 380 kB in 8s (50.5 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
28 packages can be upgraded. Run 'apt list --upgradable' to see them.
W: https://repos.insights.digitalocean.com/apt/do-agent/dists/main/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
root@fig:~#
这里有一条警告信息,是关于 DigitalOcean 自己的那个 Monitoring 软件库的信息的,暂时先忽略它。后面会有一个解决办法。
这里可以看到有28个软件包有更新,那么就执行 apt upgrade 来完成更新。
root@fig:~# apt upgrade
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following NEW packages will be installed:
linux-headers-5.15.0-30 linux-headers-5.15.0-30-generic linux-image-5.15.0-30-generic
linux-modules-5.15.0-30-generic
The following packages will be upgraded:
base-files distro-info-data git git-man libcurl3-gnutls libfribidi0 libnss-systemd libpam-systemd libssl3
libsystemd0 libudev1 linux-headers-generic linux-headers-virtual linux-image-virtual linux-virtual
motd-news-config networkd-dispatcher openssl python3-software-properties python3-twisted rsyslog snapd
software-properties-common systemd systemd-sysv systemd-timesyncd ubuntu-advantage-tools udev
28 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
10 standard security updates
Need to get 87.3 MB of archives.
After this operation, 224 MB of additional disk space will be used.
Do you want to continue? [Y/n]
选择 Y 继续,完成安装,因为有个 Linux 核心的更新,升级完成后会询问是否重启,按回车 OK,还会问有哪些服务要重启,这里就不用管它了,因为整个系统都要重启了,再按一次回车就可以了。对了重启命令是 shutdown now -r
。
安装 Webmin 控制面板,SSH 安全设置
为什么要安装 Webmin?
主要就是我习惯使用,用了很多年了。一直在用 Webmin 管理面板,可以很方便的更新系统,安装 perl 包,添加 MySQL 数据库;第二,在出现错误的时候,查看 log 日志,还有很多很多其它功能。
安装 Webmin
参考 webmin 官方的安装 Webmin 到 Debian 系统的做法。
使用添加 Webmin APT 源的方式来安装。新建一个文件 nano /etc/apt/sources.list.d/webmin.list
deb [signed-by=/usr/share/keyrings/jcameron-key.gpg] https://download.webmin.com/download/repository sarge contrib
接着导入GPG 密钥如下。
cd /root
wget https://download.webmin.com/jcameron-key.asc
cat jcameron-key.asc | gpg --dearmor >/usr/share/keyrings/jcameron-key.gpg
再之后就可以安装了。
apt-get install apt-transport-https
apt-get update
apt-get install webmin
安装完成之后,在桌面浏览器(比如 chrome)中输入下面的网址来访问安装好的 Webmin 控制面板。
https://147.182.232.40:10000
然后会出现"Your connection is not private"的警告信息,点击 Advanced。