












安装 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 的安装了。
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。