2026-07-25 04:11:36
在介绍了如何安装 Ubuntu 26.04 LTS, Webmin, Nginx, MariaDB, PHP8.5-FPM,Perl-Fastcgi 到 DigitalOcean 的 VPS上后,有些补充内容。
比如 acme.sh 现在安装的 SSL 证书,默认已经是 ecc 证书了,就是 ecc-256 (prime256v1, "ECDSA P-256")。
然而还有一些需要说明的情况就放在了下面。
实际使用上,现在我已经很少再用 TCP Wrap 来作安全防护,而是使用了 nftables 防火墙,配合 fail2ban 来组合配合。
Ubuntu 26.04. 已经默认安装了 nftables 了,如果没有的话,就是用下面的来安装。
davidyin@pecan:~$ sudo service nftables status
○ nftables.service - nftables
Loaded: loaded (/usr/lib/systemd/system/nftables.service; disabled; preset: enabled)
Active: inactive (dead)
Docs: man:nft(8)
http://wiki.nftables.org
而 Ubuntu 26.04 默认是安装使用了 UFW,作为 nftables 的前端。这里我不打算使用。就需要卸掉。
sudo systemctl disable --now ufw sudo apt remove ufw
当然还需要启用 nftables。安装 fail2ban.
sudo systemctl enable --now nftables
sudo apt install fail2ban
fail2ban 有几个常见命令,如下:
sudo systemctl enable fail2ban
sudo systemctl start fail2ban
sudo fail2ban-client version
返回 1.1.0,这是版本号。还有两个命令可以看 fail2ban 的状态,Ban了那些服务,哪些 IP 地址。
davidyin@pecan:~$ sudo fail2ban-client status
Status
|- Number of jail: 1
`- Jail list: sshd
davidyin@pecan:~$ sudo fail2ban-client status sshd
Status for the jail: sshd
|- Filter
| |- Currently failed: 6
| |- Total failed: 6
| `- Journal matches: _SYSTEMD_UNIT=ssh.service + _COMM=sshd
`- Actions
|- Currently banned: 0
|- Total banned: 0
`- Banned IP list:
fail2ban 的配置文件,最好是修改 /etc/fail2ban/jail.local 这个是本机文件,以后升级系统,升级 fail2ban 也不会改变该文件。
有些参数需要设置在 jail.local 里面。比如下面,在 ignoreip 这里填入自己的 ip 地址,这样就不会不小心把自己给关在外面了。
另外还有 收件地址等等。
在 Webmin 管理界面,也有 Fail2Ban 的管理模块,使用也是很方便的。我通常就在 webmin 里面做修改。
![]()
大概启用 fail2ban 一个小时之后,看一眼封掉多少 IP。
在大约二十个小时之后,大约被封禁掉78个 IP 地址。大多是那些从各个机房过来扫描的。
在开机大约七天后,再次查看了 Fail2Ban 的记录,在 SSH服务上,各种登录尝试失败后的情况,被封禁的 IP 数量达到 831 次。当前还有 95 个 IP 地址。
这个对于网络传输很重要。好的这是 Google 搞出来的东西,BBR。
sudo nano /etc/sysctl.d/99-network.conf
添加内容
net.core.default_qdisc=fq
net.ipv4.tcp_congestion_control=bbr
之后应用它
sudo sysctl -p /etc/sysctl.d/99-network.conf
有两条命令可以用来查看情况,下面第一条是看有哪些可用的拥塞算法,第二条是看当前生效的是哪一种拥塞算法。
davidyin@pecan:~$ sudo sysctl net.ipv4.tcp_available_congestion_control
net.ipv4.tcp_available_congestion_control = reno cubic bbr
davidyin@pecan:~$ sudo sysctl -n net.ipv4.tcp_congestion_control
bbr
对于使用 php 重度用户,其实还需要开启 jit。
编辑 /etc/php/8.5/fpm/conf.d/10-opcache.ini
修改内容,增加下面这三项主要的修改。
opcache.enable_cli=1
opcache.jit_buffer_size=64M
opcache.jit=tracing
修改完成后,重启 php8.5-fpm 服务,用我常用的一些 php 性能测试 script,比较修改前后的测试结果。可以大体得出一个结论,速度快了。
用 bench.php 测试,平均时间从 0.270s 提高到了 0.0898秒。
用 MicroBench 测试,平均时间从 1.8302 提高到 0.7874
用 bubble.php 测试,时间从 0.08230 提高到 0.0393.
用 X Prober v10.0.1 内置的 Server Benchmark 测试,463,062 提高到了 506,317。
这种性能提高不只是看数字好看,而是能实际感受得到的。
2026-07-25 03:20:05
安装 Ubuntu 26.04 LTS, Webmin, Nginx, MariaDB, PHP8.5-FPM,Perl-Fastcgi 到 DigitalOcean 的 VPS上。
之前介绍了如何在 DigitalOcean 创建新 VPS。并且完成基本的 Ubuntu 26.04. LTS的系统。然后介绍了如何安装 Webmin 主机控制面板,时区设置和 SSH 的安全设置。再之后说明一下如何用之前的新添加的用户来安装 Nginx Web 服务器和 MairaDB 数据库服务器。以及安装完 php 语言和 SSL 证书的申请。
现在要来介绍一下如何配置 nginx 上的加密站点了。
修改 Nginx 配置文件,以满足证书的使用之前,先执行一个命令,来生成一个4096位的 dhparam 文件。
cd ~/ssl
openssl dhparam -out dhparam.pem 4096
需要等待一段时间,这个命令会执行比较长时间。
先来确认各个部分的版本信息,下面要用到。
davidyin@walnut:~/ssl$ nginx -v
nginx version: nginx/1.28.3 (Ubuntu)
davidyin@walnut:~/ssl$ openssl version
OpenSSL 3.0.13 30 Jan 2024 (Library: OpenSSL 3.0.13 30 Jan 2024)
配置参数的来源根据 https://configurator.tlsref.org/这个生成器来产生。
我会建议采取 Modern 方式的配置。
主机配置文件做相应的修改, http 网站重定向到 https。 采用 http2,还有就是 HSTS 与载入配置,最后完整的 u26.webexample.win 的配置文件,可以到 gist 查看,仅供参考。
到 SSL Labs 检测 SSL的配置,评分得到 A。
当然也可以到 SSLShopper 去做一下检测,看看证书是否都正确。
![]()
下面是对我而言很重要的语言支持,因为我有用 MovableType 系统,SEO网站优化 就是用它搭建的。而它是由 perl 语言支持的。
libfcgi-perl 可能已经有了,但下面还是再执行一遍安装,以防缺失。
sudo apt install fcgiwrap spawn-fcgi libfcgi-perl
然后来配置 fcgiwrap 多 worker。
sudo tee /etc/systemd/system/fcgiwrap-multi.service << 'EOF' [Unit] Description=FastCGI wrapper (multi-worker) After=network.target [Service] Type=simple ExecStart=/usr/bin/spawn-fcgi -F 4 -s /var/run/fcgiwrap.socket -u www-data -g www-data -- /usr/sbin/fcgiwrap ExecStopPost=/bin/rm -f /var/run/fcgiwrap.socket Restart=always [Install] WantedBy=multi-user.target EOF sudo systemctl disable fcgiwrap sudo systemctl disable fcgiwrap.socket sudo systemctl daemon-reload sudo systemctl enable fcgiwrap-multi sudo systemctl start fcgiwrap-multi davidyin@pecan:~$ ps aux | grep fcgiwrap www-data 11402 0.0 0.2 5116 2808 ? Ss 00:02 0:00 /usr/sbin/fcgiwrap -f www-data 11454 0.0 0.2 5116 2416 ? Ss 00:02 0:00 /usr/sbin/fcgiwrap www-data 11455 0.0 0.2 5116 2348 ? Ss 00:02 0:00 /usr/sbin/fcgiwrap www-data 11456 0.0 0.2 5116 2352 ? Ss 00:02 0:00 /usr/sbin/fcgiwrap www-data 11457 0.0 0.2 5116 2420 ? Ss 00:02 0:00 /usr/sbin/fcgiwrap davidyin 11838 0.0 0.2 7256 2400 pts/0 S+ 00:03 0:00 grep --color=auto fcgiwrap
现在就有 4 个 worker 可以为它工作了。
最后在 Nginx 的配置文件中添加下面这块。
location ~ \.pl|cgi$ {
fastcgi_pass unix:/var/run/fcgiwrap.socket;
fastcgi_index index.pl;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
保存配置文件并重启 Nginx 服务。 接下来要测试,是否可以让 perl 文件运行。 新添加一个文件到 /home/davidyin/u26.webexample.win/index.pl 内容如下:
在服务器上的文件后缀名必须是 pl,然后给与可执行权限。
chmod 755 index.pl
在浏览器中输入 https://u26.webexample.win/index.pl
如果看到下面的输出内容,那就对了。
![]()
看到上面的信息,就可以证明 Perl 可以正常地在网站执行。
到目前为止,已经配置好一个 DigitalOcean 的 VPS,安装好了 Ubuntu 26.04 Lts,Webmin 管理控制面板,以及 Nginx web 服务器,MariaDB 数据库服务器,php8.5-fpm 服务,Perl-Fastcgi 服务,免费的 SSL 证书。配置好了一个测试网站。 之后,需要安装那些由 php 编写的网站程序, Perl 编写的网站程序,都可以安装了。
2026-07-25 02:20:33
安装 Ubuntu 26.04 LTS, Webmin, Nginx, MariaDB, PHP8.5-FPM,Perl-Fastcgi 到 DigitalOcean 的 VPS上。
DavidYin 介绍了如何在 DigitalOcean 创建新 VPS。并且完成基本的 Ubuntu 26.04 LTS的系统。然后介绍如何安装 Webmin 主机控制面板,时区设置和 SSH 的安全设置。再之后说明一下如何用之前的新添加的用户来安装 Nginx Web 服务器和 MairaDB 数据库服务器。
现在就是很重要的语言支持部分了。因为我用的最多的就是 php 以及 perl 语言。所以这两部分就是重点了。
Ubuntu 26.04 LTS 仓库所包含的是 php8.5.4,目前 php 官方支持的主力版本是 8.4,8.5,而 8.2,8.3 则是在安全补丁支持阶段。所以直接使用 Ubuntu 的就已经是很新的版本了。
sudo apt install php8.5 php8.5-fpm php8.5-cli php8.5-common php8.5-mbstring php8.5-gd php8.5-intl php8.5-xml php8.5-mysql php8.5-zip php8.5-curl
安装完成后,执行 php -v 命令,可以看到版本信息。
davidyin@pecan:~$ php -v
PHP 8.5.4 (cli) (built: Jul 16 2026 18:56:38) (NTS)
Copyright (c) The PHP Group
Built by Ubuntu
Zend Engine v4.5.4, Copyright (c) Zend Technologies
with Zend OPcache v8.5.4, Copyright (c), by Zend Technologies
可以确认当前版本为 php 8.5.4. 然后再看一眼,php8.5-frpm 服务是否已经起来。

说明:下面这些都是用来举例说明所用的,在实际使用中请用真实的数据。
IP: 144.126.221.243
Domain: u26.webexample.win
username: davidyin
接下来我要设置一个 vhost,就是一个虚拟主机,我用的域名是 u26.webexample.win,此为举例而已。 到域名服务商的网站,专门设置域名记录的地方,把 u26.webexample.win 的 A 记录指向此 VPS 的 IP 地址,生效可能需要十分钟或更久,为快捷,可以在所操作的Windows hosts 文件添加纪录使之在本地立即可用。 新建一个主机配置文件,u26.conf,如下。
log_format main '$remote_addr - $remote_user [$time_local] $status '
'"$request" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
server {
listen 80;
server_name u26.webexample.win;
access_log /var/log/nginx/host.access.log main;
root /home/davidyin/u26.webexample.win;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ = 404;
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.5-fpm.sock;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
保存退出,然后执行 sudo nginx -t 命令看看,是否配置文件正确。若正确,就重启 Nginx 服务,使配置生效。
sudo service nginx restart
在/home/davidyin/u26.webexample.win/下新建一个文件 info.php
输入如下内容:
<?php
phpinfo();
回到桌面浏览器中,输入网址 http://u26.webexample.win/info.php,如果看到下面这些内容,就表示 php 安装正确, nginx 也运行正确。
有时候会出现奇怪的问题,找不到文件啊,没有权限啊。这是最好的解决方法,就是重启服务器。有时候是配置未生效。
如果出现问题,或者是页面错误,可以查看这两个日志文件。
/var/log/nginx/host.access.log
/var/log/nginx/error.log
至此,php8.5 已经安装完毕,并且虚拟主机也可以使用 php 语言了。
如果是商用,或者愿意购买一年期的证书,DavidYin建议到 Gogetssl 购买,这里价格最优,无限重签,不限服务器。目前的证书可以购买5年的,但是实际签发的证书都是半年的,这是现在所有CA 的国际标准,到时重新签发一次,直到购买的年份用完为止。买多年的会便宜一点。
Gogetssl 证书的好处是你买了一个证书给域名 A 用,如果这个域名不用了,还可以签发给域名 B 使用剩下的时间。
免费证书这里我采用 Zerossl 的 SSL 证书。使用了 Neilpang 的 ACME.SH 来安装。每月自动续签。
先安装工具。
curl https://get.acme.sh | sh -s [email protected]
接下来,重新登入SSH,相当于重新载入 BASH 环境,因为上面的安装已经把路径配置到 Bash 中了,并且自动创建了一个 bash 的别名,方便使用,直接输入 acme.sh 命令就可以了。另外还自动创建了一个 cronjob,每天零点自动检测所有的证书,如果快过期,就会自动更新。
验证域名的方式有两种,DNS 和 http,这次我用了 http 方式来验证。
上面一步安装好后,需要先执行一下 source ~/.bashrc , 以让环境参数生效。
davidyin@pecan:~$ acme.sh --issue -d u26.webexample.win --webroot /home/davidyin/u26.webexample.win
[Wed Jul 22 23:17:10 PDT 2026] Using CA: https://acme.zerossl.com/v2/DV90
[Wed Jul 22 23:17:10 PDT 2026] Single domain='u26.webexample.win'
[Wed Jul 22 23:17:15 PDT 2026] Getting webroot for domain='u26.webexample.win'
[Wed Jul 22 23:17:15 PDT 2026] Verifying: u26.webexample.win
[Wed Jul 22 23:17:18 PDT 2026] Processing. The CA is processing your order, please wait. (1/30)
[Wed Jul 22 23:17:22 PDT 2026] Success
[Wed Jul 22 23:17:22 PDT 2026] Verification finished, beginning signing.
[Wed Jul 22 23:17:22 PDT 2026] Let's finalize the order.
[Wed Jul 22 23:17:22 PDT 2026] Le_OrderFinalize='https://acme.zerossl.com/v2/DV90/order/9vGSFUWWbZI18Dgg6xOtHQ/finalize'
[Wed Jul 22 23:17:24 PDT 2026] Order status is 'processing', let's sleep and retry.
[Wed Jul 22 23:17:24 PDT 2026] Sleeping for 15 seconds then retrying
[Wed Jul 22 23:17:40 PDT 2026] Polling order status: https://acme.zerossl.com/v2/DV90/order/9vGSFUWWbZI18Dgg6xOtHQ
[Wed Jul 22 23:17:42 PDT 2026] Downloading cert.
[Wed Jul 22 23:17:42 PDT 2026] Le_LinkCert='https://acme.zerossl.com/v2/DV90/cert/aXnfE7FQTsSqhmxD7aCpVg'
[Wed Jul 22 23:17:44 PDT 2026] Cert success.
-----BEGIN CERTIFICATE-----
MIIDhzCCAyygAwIBAgIQP0RKPW1WFzsDCTAZ2AAP3TAKBggqhkjOPQQDAjBGMQsw
CQYDVQQGEwJBVDEVMBMGA1UEChMMWmVyb1NTTCBHbWJIMSAwHgYDVQQDExdaZXJv
U1NMIEVDQyBEViBTU0wgQ0EgMjAeFw0yNjA3MjMwMDAwMDBaFw0yNjEwMjEyMzU5
NTlaMB0xGzAZBgNVBAMTEnUyNi53ZWJleGFtcGxlLndpbjBZMBMGByqGSM49AgEG
CCqGSM49AwEHA0IABNis5Z7Jdv/8/hMiELxnX0yvXKBxLKk6cwZ2hcbM2+eQQqC8
中间省略
AiEAsXwlwSjlPiMRFS5KuloJBZ7EC6R3+gV61Dvvc8f63ZgCICORhj/RKrXOBP8h
QkztHkWqmXLRoGaPnG6Ujwoz7ppdMB0GA1UdEQQWMBSCEnUyNi53ZWJleGFtcGxl
LndpbjAKBggqhkjOPQQDAgNJADBGAiEA+ZwEXzQApjTiU5aGMOG3R9mTqoezIrtG
lP0ALMIbfZcCIQDcIq2Lg6PpLaOoK8i8by4qAMEWcZf6sTkze5LUXnPssw==
-----END CERTIFICATE-----
[Wed Jul 22 23:17:44 PDT 2026] Your cert is in: /home/davidyin/.acme.sh/u26.webexample.win_ecc/u26.webexample.win.cer
[Wed Jul 22 23:17:44 PDT 2026] Your cert key is in: /home/davidyin/.acme.sh/u26.webexample.win_ecc/u26.webexample.win.key
[Wed Jul 22 23:17:44 PDT 2026] The intermediate CA cert is in: /home/davidyin/.acme.sh/u26.webexample.win_ecc/ca.cer
[Wed Jul 22 23:17:44 PDT 2026] And the full-chain cert is in: /home/davidyin/.acme.sh/u26.webexample.win_ecc/fullchain.cer
[Wed Jul 22 23:17:45 PDT 2026] ARI suggestedWindow: 2026-10-06T23:59:59Z to 2026-10-08T23:59:59Z
[Wed Jul 22 23:17:45 PDT 2026] Next renewal time picked from ARI window: 2026-10-08T06:17:44Z
验证正确,就会自动签发证书,证书会临时先存放在一个工作目录,现在我要指定一个目录存放: /home/davidyin/ssl/。 之后就是安装证书到该目录。
acme.sh --install-cert -d u26.webexample.win \
--key-file /home/davidyin/ssl/key \
--fullchain-file /home/davidyin/ssl/cert \
--reloadcmd "service nginx force-reload"
就这样,证书也签发好了,也安装到指定位置,接下来会介绍如何在 nginx 的配置文件中,设置证书路径,设置 https,设置重定向,还有 perl-fastcgi等等。
2026-07-25 02:01:54
安装 Ubuntu 26.04 (LTS), Webmin, Nginx, MariaDB, PHP8.5-FPM,Perl-Fastcgi 到 DigitalOcean 的 VPS
在第一部分,DavidYin 介绍了如何在 DigitalOcean 创建新 VPS。并且完成基本的 Ubuntu 26.04 LTS的系统。
第二部分介绍如何安装 Webmin 主机控制面板,SSH 的安全设置,时区设置和添加新用户 。
下面 DavidYin 要说明一下如何用之前的新添加的用户来安装 Nginx Web 服务器和 MairaDB 数据库服务器。
先用第二部分时添加的新用户 davidyin 登上 ssh 窗口。
Ubuntu 26.04 LTS server 版目前的 Nginx 还是 Legacy 版本,可以直接安装,当前的最新版本是 1.28.0。
输入命令安装。
davidyin@pecan:~$ sudo apt install nginx
Installing:
nginx
Installing dependencies:
nginx-common
Suggested packages:
fcgiwrap nginx-doc ssl-cert
Summary:
Upgrading: 0, Installing: 2, Removing: 0, Not Upgrading: 0
Download size: 655 kB
Space needed: 1860 kB / 21.8 GB available
Continue? [Y/n]
Get:1 http://mirrors.digitalocean.com/ubuntu resolute-updates/main amd64 nginx-common all 1.28.3-2ubuntu1.8 [37.7 kB]
Get:2 http://mirrors.digitalocean.com/ubuntu resolute-updates/main amd64 nginx amd64 1.28.3-2ubuntu1.8 [617 kB]
Fetched 655 kB in 0s (16.0 MB/s)
Preconfiguring packages ...
Selecting previously unselected package nginx-common.
(Reading database ... 159523 files and directories currently installed.)
Preparing to unpack .../nginx-common_1.28.3-2ubuntu1.8_all.deb ...
Unpacking nginx-common (1.28.3-2ubuntu1.8) ...
Selecting previously unselected package nginx.
Preparing to unpack .../nginx_1.28.3-2ubuntu1.8_amd64.deb ...
Unpacking nginx (1.28.3-2ubuntu1.8) ...
Setting up nginx-common (1.28.3-2ubuntu1.8) ...
Created symlink '/etc/systemd/system/multi-user.target.wants/nginx.service' → '/usr/lib/systemd/system/nginx.service'.
Setting up nginx (1.28.3-2ubuntu1.8) ...
* Upgrading binary nginx [ OK ]
Processing triggers for man-db (2.13.1-1build1) ...
Processing triggers for ufw (0.36.2-9build1) ...
Scanning processes...
Scanning linux images...
Running kernel seems to be up-to-date.
No services need to be restarted.
No containers need to be restarted.
No user sessions are running outdated binaries.
No VM guests are running outdated hypervisor (qemu) binaries on this host.
安装完成后,可以看一下安装后的版本以及编译信息
davidyin@pecan:~$ nginx -V
nginx version: nginx/1.28.3 (Ubuntu)
built with OpenSSL 3.5.5 27 Jan 2026
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -Werror=implicit-function-declaration -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -ffile-prefix-map=/build/nginx-NbCeiP/nginx-1.28.3=. -flto=auto -ffat-lto-objects -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -fdebug-prefix-map=/build/nginx-NbCeiP/nginx-1.28.3=/usr/src/nginx-1.28.3-2ubuntu1.8 -fPIC -Wdate-time -D_FORTIFY_SOURCE=3' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,--package-metadata=%7B%22type%22:%22deb%22%2C%22os%22:%22ubuntu%22%2C%22name%22:%22nginx%22%2C%22version%22:%221.28.3-2ubuntu1.8%22%2C%22architecture%22:%22amd64%22%7D -flto=auto -ffat-lto-objects -Wl,-z,relro -Wl,-z,now -fPIC' --override-system=Linux --override-release=3.16.0 --override-machine=x86_64 --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=stderr --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --modules-path=/usr/lib/nginx/modules --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-compat --with-debug --with-pcre-jit --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_v2_module --with-http_v3_module --with-http_dav_module --with-http_slice_module --with-threads --build=Ubuntu --with-http_addition_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_secure_link_module --with-http_sub_module --with-mail_ssl_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-stream_realip_module --with-http_geoip_module=dynamic --with-http_image_filter_module=dynamic --with-http_perl_module=dynamic --with-http_xslt_module=dynamic --with-mail=dynamic --with-stream=dynamic --with-stream_geoip_module=dynamic
在浏览器中输入 IP 地址,看看到默认 Nginx 网页是否已经起来。
![]()
它其实就是一个 MySQL 服务器,目前 Ubuntu 26.04 LTS 软件仓库中包含的默认 MariaDB 版本是 11.8.6,此版本是 MariaDB 官方所维护的多个稳定版本之一,在我粗浅的看来,11.4以上的这些个都是稳定版本。
所以也是直接安装就可以了。
输入安装命令。
sudo apt install mariadb-server
安装完成后,就需要修改 MySQL 默认的 root 用户的密码。默认是空密码。
sudo mariadb_secure_installation
添加密码给数据库的 root 用户。命令执行过程中的设置如下:
注意两点,一个是要设置MysQL 服务器的 root 密码,默认是没有密码的。其它的我都选的默认值。很多次看到某些网站被黑,说的都是数据库没有密码保护之类的疏忽。
davidyin@pecan:~$ sudo mariadb-secure-installation
NOTE: MariaDB is secure by default in Debian. Running this script is
useless at best, and misleading at worst. This script will be
removed in a future MariaDB release in Debian. Please read
/usr/share/doc/mariadb-server/README.Debian.gz for details.
Enter root user password or leave blank:
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.
You already have your root account protected, so you can safely answer 'n'.
Switch to unix_socket authentication [Y/n]
Enabled successfully (or at least no errors was emitted)!
Reloading privilege tables..
... Success!
You already have your root account protected, so you can safely answer 'n'.
Change the root password? [Y/n]
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n]
SQL executed without errors!
The operation might have been successful, or it might have not done anything.
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n]
SQL executed without errors!
The operation might have been successful, or it might have not done anything.
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n]
- Dropping test database...
SQL executed without errors!
The operation might have been successful, or it might have not done anything.
- Removing privileges on test database...
SQL executed without errors!
The operation might have been successful, or it might have not done anything.
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n]
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
然后回到 Webmin 控制面板的地方,左侧: Refresh Modules,在经过一点点时间后, Webmin 系统自动就发现了我已经安装了 MySQL Databse Server。
点击左侧菜单后,就能看到已经认出 MariaDB Database Server 11.8.6
在这里,可以用来添加新的数据库,新的Mysql 用户等等,都是为了以后添加网站,比如 Wordpress 之类的时候使用的。
至此两个服务器的安装已经完成,接下来就要介绍 php8.5-fpm 以及 Perl-fastcgi 的安装了。
2026-07-25 01:53:30
安装 Ubuntu 26.04 (LTS), Webmin, Nginx, MariaDB, PHP8.5-FPM,Perl-Fastcgi 到 DigitalOcean 的 VPS
在第一部分,DavidYin 介绍了如何在 DigitalOcean 创建新 VPS,选择基本的 Ubuntu 26.04 LTS的系统。
下面是介绍如何安装 Webmin 这个主机控制面板和 SSH 的安全设置。这非常重要,安全性的事情,如何小心都不为过。
首先,我使用的是 Putty,这是一个 SSH 工具,先用 putty 登录 VPS,IP 地址可以登录到 DigitalOcean 后台看到,用户名就是 root,密码是刚刚自己设置的那个密码。
登录到 VPS 之后,一登录,就可看到显示着有 6 个更新需要马上进行,都是标准安全更新。
执行 apt update,查询软件库的更新信息。
root@pecan:~# apt update
Hit:1 http://security.ubuntu.com/ubuntu resolute-security InRelease
Hit:2 https://repos-droplet.digitalocean.com/apt/droplet-agent main InRelease
Hit:3 http://mirrors.digitalocean.com/ubuntu resolute InRelease
Hit:4 http://mirrors.digitalocean.com/ubuntu resolute-updates InRelease
Hit:5 http://mirrors.digitalocean.com/ubuntu resolute-backports InRelease
61 packages can be upgraded. Run 'apt list --upgradable' to see them.
root@pecan:~#
现在看到有 61 个包需要升级。
root@pecan:~# apt upgrade
Upgrading:
bpftool libfwupd3 libpython3.14-minimal linux-virtual snapd vim-common
curl libgcrypt20 libpython3.14-stdlib ntfs-3g tar vim-runtime
fwupd libgssapi-krb5-2 libsqlite3-0 openssh-client tzdata vim-tiny
gawk libk5crypto3 libssh2-1t64 openssh-server ubuntu-kernel-accessories wget
gzip libkrb5-3 linux-headers-generic openssh-sftp-server ubuntu-minimal xxd
iproute2 libkrb5support0 linux-headers-virtual python3-httplib2 ubuntu-pro-client
krb5-locales libnghttp2-14 linux-image-virtual python3-idna ubuntu-pro-client-l10n
libcurl3t64-gnutls libnss3 linux-libc-dev python3.14 ubuntu-server
libcurl4t64 libntfs-3g89t64 linux-perf python3.14-gdbm ubuntu-standard
libfreetype6 libpython3.14 linux-tools-common python3.14-minimal vim
Installing dependencies:
linux-headers-7.0.0-28 linux-main-modules-zfs-7.0.0-28-generic linux-tools-7.0.0-28-generic
linux-headers-7.0.0-28-generic linux-modules-7.0.0-28-generic
linux-image-7.0.0-28-generic linux-tools-7.0.0-28
Suggested packages:
linux-tools
Not upgrading yet due to phasing:
apport apport-core-dump-handler python3-apport python3-problem-report python3-software-properties software-properties-common
Summary:
Upgrading: 55, Installing: 7, Removing: 0, Not Upgrading: 6
47 standard LTS security updates
Download size: 305 MB
Space needed: 318 MB / 22.5 GB available
└─ in /boot: 107 MB / 856 MB available
Continue? [Y/n]
按 Y,继续升级。中间会问你,SSHD配置文件是否要更改,我选择的是第二个选项,保持原来的版本。然后再次重启系统,对了重启命令是 shutdown now -r。
为什么要安装 Webmin?
主要就是我习惯使用,用了很多年了。一直在用 Webmin 管理面板,可以很方便的更新系统,安装 perl 包,添加 MySQL 数据库;第二,在出现错误的时候,查看 log 日志,还有很多很多其它功能。
参考 webmin 官方的安装 Webmin的方法。
先下载源库的文件,再添加源。
curl -o webmin-setup-repo.sh https://raw.githubusercontent.com/webmin/webmin/master/webmin-setup-repo.sh
sudo sh webmin-setup-repo.sh
然后就可以输入下面的命令开始安装 webmin了。
sudo apt-get install webmin --install-recommends
安装完成之后,在桌面浏览器(比如 Firefox)中输入下面的网址来访问安装好的 Webmin 控制面板。
https://144.126.221.243:10000
然后会出现"Be careful. Something doesn't look right."的警告信息,点击 Advanced 按钮,点击 "Proceed to 144.126.221.243 (Risky)",就可以继续载入登录页面了。
看到登录页面,输入之前的 root 和对应的密码。
Webmin 默认安装的用户界面是响应式,之前我一直用的是经典样式,现在我也已经习惯使用响应式了。
登入之后,看到有提示,6个软件包需要更新。一路点击更新之。
看看当前我所创建的这个 VPS 的参数:
为了 SSH 的安全,我会在 TCP wrappers 处添加两条规则,只允许来自指定的 IP 地址的电脑以 SSH 的方式连上服务器。
左侧,Networking 》TCP Wrappers。
在 Allow 规则处,允许 ALL Services, Remote Hosts 的地方输入服务器 IP 和我所指定的IP,(就是我自己的 IP 地址)在 Deny 规则处,Services 填写 sshd ,Remote Hosts 选 All。
这样设置完成后,来自指定 IP 地址的 SSH 访问不会受影响,除此之外的 IP,若访问 SSH 服务的话,就会直接被拒绝。比如下面的记录可以看到,服务器才刚刚创立十分钟,就有莫名奇妙的 IP 试图以 root 身份连上 SSH,用不同的端口,尝试密码,当然出错返回,但都会消耗 VPS 资源,大多是自动扫描的工具,设置 TCP Wrapper 之后,就直接 refused 了,连密码尝试的机会都不会给。
在 webmin 上面可以选 System 》 System Logs RS 》File /var.log/auth.log
看sshd 的日志,最下面的一行 refused connect from 就是一条。
Ubuntu 系统平时不建议以 root 用户直接登录操作,而是应该用普通用户,如果需要执行 root 用户的权限,那就采用 sudo 方式。下面就是在 Webmin 的管理面板中进行添加新用户。
在左侧,选择 System 》 Users and Groups, 然后选择 Create a new user,比如用户名输入 davidyin,选择 Normal password 输入自己设定的密码,当然更安全的是使用 SSH public key的方式来登入, Shell 这块我会选择 /bin/bash ,然后在 primary group 的地方,默认是选择已存在的用户组 users。在 Second group 的地方我会把 sudo 组加入,这样以后就只用登入这个用户来操作,即使执行更高权限的操作,也只需要 sudo 就可以了。
记得密码设置的复杂一些。
很多年前,我有用 proftpd 作为 VPS 上的 FTP 服务器,但是后来觉得既然可以直接使用 SFTP,就是 SSH File Transfer Protocol,简而言之,就是利用 SSH 来传输文件的方式,为什么还要安装 FTP服务器呢?第一,ssh 更加安全;第二,服务器上可以少安装一样服务,节约内存,并且少一个可能的安全漏洞。
设置时区就可以自动把系统时间同步到我所在的本地时间。
左侧,Hardware 》 System Time, 选择 Change Timezone 标签,在时区修改的下拉菜单,改为 America/Vancouver (MST -BC (most areas)),点击保存。现在 VPS 显示的时间就是我所在的温哥华地区了。
今年开始就是永久夏令时了,所以时区就从 PST,变成了 MST。
在 Time server sync 这个 tab 下面,可以设置让时钟定时校准。
在 Ubuntu 26.04 系统,是使用 chrony 服务来同步的。
而校时服务器,Ubuntu 26.04 的 chrony 默认是保存在 /etc/chrony/sources.d/ubuntu-ntp-pools.sources
其中已经设置了NTS 代替了 NTP。也已经设了相关的服务器。这部分不太了解,能用就行。
至此, Ubuntu 26.04 LTS,Webmin控制面板,以及时区设置,SSH的安全设置都完成了。接下来是介绍如何安装 Nginx Web 服务器,MariaDB数据库服务器,php等等。
2026-07-25 01:08:56
Ubuntu 26.04 LTS 在2026年4月23日发布,这几个月一直很忙,所以拖到今天才来介绍如何安装 Ubuntu 26.04 (LTS), Webmin, Nginx, MariaDB, PHP-FPM,Perl-Fastcgi 到 DigitalOcean 的 VPS。
基本上每次Ubuntu的Lts版本发布,我都会写一下有关的教程。
在2015年,我发布了 安装Nginx, MySQL, PHP-FPM, Perl-Fastcgi到Ubuntu 14.04 LTS
在2017年,我发布了 安装 Ubuntu 16.04, Webmin, Nginx, MariaDB, PHP7.1-FPM,Perl-Fastcgi 到 Vultr.com 的 VPS
在 2018年, 则是发布了 安装 Ubuntu 18.04, Webmin, Nginx, MariaDB, PHP7.2-FPM,Perl-Fastcgi 到 Linode 的 VPS
在2020年,发布了 安装 Ubuntu 20.04, Webmin, Nginx, MariaDB, PHP7.4-FPM,Perl-Fastcgi 到 DigitalOcean 的 VPS
在 2022年, 发布了 安装 Ubuntu 22.04 (LTS), Webmin, Nginx, MariaDB, PHP8.1-FPM,Perl-Fastcgi 到 DigitalOcean 的 VPS
在 2024年,发布了 安装 Ubuntu 24.04 (LTS), Webmin, Nginx, MariaDB, PHP8.3-FPM,Perl-Fastcgi 到 DigitalOcean 的 VPS
本站曾经就是放在了 DigitalOcean ,所以 DavidYin 来介绍一下新的 VPS 服务器安装过程,包含的软件如下:
免责:整个安装过程,只是个人经验,不含任何保证,采用者自己对服务器的安全以及数据负责。
登录 DigitalOcean 的后台,然后在 Projecs 选择一个 Project,没有的话,就新建一个。Project 是用来组织资源的,比如多个 vps,还有各种其它的服务。点击右上角的 Create,打开下拉菜单,在 Compute 部分,选择第一个选项 Droplet。Droplet 就是 DigitalOcean 的 VPS 的昵称。这家服务商名称叫做数字海洋,那么每个 VPS 就像是海洋中的一滴水珠。我猜就是这么个意思。然后就出现新建 VPS 的选项了。
首先,选择数据中心的地区,也是机房位置,比如我这里选择了 旧金山的 3 号机房。(选择机房的原则就是距离你自己近一点,或者说速度更快一点,通常物理距离近一点的地方速度会更快)。如图,因为之前已经用过 SFO3,所以它被列在上面了,而下拉菜单里面是其它各个可用的数据中心。
第二个是 VPC network,我没有改,就用默认的。这里网络设置的用处是可以在同一个 VPC 网络内,你使用的多个服务器之间可以私有 IP 地址进行通讯,不走公网,不会暴露到公网上。
镜像选择部分,点击 Ubuntu,在版本选择下拉菜单,选择 Ubuntu 26.04 (LTS) x64 版本。可以注意到在OS的边上,还有一个 Solutions(287) 和自定义镜像,其中 Solutions 就是很多第三方做好的镜像,可以直接使用,比如 Docker, OpenClaw 等等。 而自定义镜像则是你自己上传的。
接着是 Plan,现在 DigitalOcean 有五类计划,包括 Basic,General Purpose, CPU-Optimized, Memory-Optimized 和 Storage-Optimized。我这里就选择基本计划, Basic,
选了计划之后,还有 CPU 类型,一般都是选择 Premium CPU(Intel 和 AMD 都可以,看你自己的喜好。之后就是在不同配置中选择最小的那个,暂时就可以了,包括 1CPU, 1GB RAM, 25GB 的 NVMe SSD 储存,和 1000GB 的流量。如果以后需要扩容,可以直接升级计划,无需重装的。这里我选择了 AMD 的。
接下来是一些杂项,比如 Volumes Block Storage > Additional Storage,额外的储存空间,比如套餐内的25GB不够的话,可以选。是否启用自动备份功能,这两个启用,需要额外付费。
在认证方面,默认是要使用 SSH Key来认证的,更加安全。简单起见,我选择了密码,然后在下面输入自己选择的 root 密码。之后会有加强安全的方式。
接下来是网络,默认是 IPv4,如果需要 IPv6,就也打勾选上。还有问是否要加上 monitoring,免费的。还有两个选项自己看是否需要。
数量上我选择只创建一个 VPS,并且给了它一个名字 pecan,最后还要选择所在的 project,当然我这里就选则了 SEO Blog 这个project。
在右侧的浮动框,一直会显示价格。现在可以看到总价是每月 7美元。
然后点击 Create Droplet,创建 VPS,可以看到它在工作,掐秒表不到30秒完成了创建。
创建完成后,就能看到 IP 地址了,用它能通过 SSH 连上去操作了。
这个 IP 地址 144.126.221.243 是系统分配的,当前演示就用它了,看到此文时,此 VPS 已经被销毁了,IP 地址也不再使用了。
好了,有了这些信息,就可以连接 VPS了,我用的是 Putty工具。用之前自己设定的 root 密码就可以。登入成功后,先重启一次。
目前这个VPS 就是一个 DigitalOcean 的干净 Server 系统,只有 SSH 服务安装在上面。
接下来,DavidYin 会分五篇来分别介绍,如何在 Ubuntu 26.04 LTS 服务器系统上安装 Webmin 控制面板,Nginx Web 服务器,MariaDB 数据库服务器,php8.5-FPM,以及 Perl-Fastcgi 和配置 SSL证书等内容。