Ubuntu 22.04 安装 Webmin 2.670 指南
Ubuntu 22.04.5 实测从零安装 Webmin 2.670:官方 apt 仓库、deb 离线包、tar.gz setup 三种方案完整流程与真实回显,含防爆破排障、改端口、升级降级与卸载清理。
Ubuntu 22.04 安装 Webmin 2.670 指南
目标:在 Ubuntu 22.04 服务器上从零安装 Webmin 2.670,覆盖官方 apt 仓库、deb 离线包、tar.gz 源码三种安装方案的完整流程与真实回显,并给出安装后的基础配置、升级与卸载方法。全部命令与输出均在 Ubuntu 22.04.5 LTS(x86_64)实测通过。
一、环境信息
实测环境一览(以下所有回显均来自该环境):
- 操作系统:Ubuntu 22.04.5 LTS(x86_64)
- 软件版本:Webmin 2.670(写作时官方最新稳定版,来源 webmin.com/download.html 与 GitHub Releases,查询日期 2026-10-21)、Authentic Theme 26.70
- 默认监听端口:10000(HTTPS)
- 安装路径:程序
/usr/share/webmin(deb/apt 方案)或自定义目录(tar.gz 方案);配置/etc/webmin;日志/运行时/var/webmin - 服务管理:systemd 单元
webmin.service
版本自检命令与实测回显:
cat /usr/share/webmin/version
2.670
/usr/share/webmin/bin/webmin --versions
Webmin: 2.670 [/usr/share/webmin]
Themes:
Authentic Theme: 26.70 [authentic-theme]
二、前置条件
安装前确认系统具备以下条件,逐项给出检查命令与实测回显。
2.1 系统与权限
以 root 或具备 sudo 权限的账号操作。确认系统版本:
cat /etc/os-release | head -3
PRETTY_NAME="Ubuntu 22.04.5 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
2.2 基础工具
deb/apt 方案需要 curl 或 wget;apt 源配置脚本还需要 gnupg(脚本会自动检测并安装):
apt-get update -qq && apt-get install -y curl wget
Running hooks in /etc/ca-certificates/update.d...
done.
2.3 端口检查
Webmin 默认使用 TCP 10000 端口(HTTPS)。安装前确认端口未被占用:
ss -ltn | grep 10000 || echo "port 10000 free"
port 10000 free
2.4 防火墙
若系统启用了 UFW 防火墙,需先放行 10000/tcp 再从浏览器访问(放行命令为 ufw allow 10000/tcp,随服务器自身防火墙策略执行)。云服务器还需在厂商安全组同步放行。
三、版本选型说明
官方维护三条软件源,安装脚本默认接入 stable,本指南全篇按 stable 展开:
| 源 | 用途 | 主机名 |
|---|---|---|
| webmin-stable | 稳定版(本指南所选) | download.webmin.com |
| webmin-prerelease | 候选预发布(发版前测试) | rc.download.webmin.dev |
| webmin-unstable | 开发版 | download.webmin.dev |
(来源:官方 webmin-setup-repo.sh 脚本头部默认值,2026-10-21 实测读取。)
版本核实方法:写作时最新稳定版为 2.670,可通过官方下载页 https://www.webmin.com/download.html(页面提供 webmin-2.670.tar.gz)或 GitHub Releases 页 https://github.com/webmin/webmin/releases 核对;安装后用 cat /usr/share/webmin/version 回读实测版本号。
四、在线安装方案(A:官方 apt 仓库,推荐)
4.1 方案说明
官方推荐路径:运行官方仓库配置脚本,自动完成「签名密钥导入 + apt 源写入」,然后随系统包管理器安装。优点:一条命令接入官方源,后续升级随 apt upgrade 自动完成;缺点:需要联网。
4.2 配置官方软件源
下载并运行官方脚本:
curl -o webmin-setup-repo.sh https://raw.githubusercontent.com/webmin/webmin/master/webmin-setup-repo.sh
sh webmin-setup-repo.sh
脚本默认会交互确认,加 -f 可跳过确认直接执行。实测完整回显(干净系统,sh webmin-setup-repo.sh -f):
Installing required gnupg from OS repos ..
.. done
Downloading Webmin Developers key ..
.. done
Installing Webmin Developers key ..
.. done
Setting up Webmin stable repository ..
.. done
Cleaning repository metadata ..
.. done
Downloading repository metadata ..
.. done
Webmin and Usermin can be installed with:
apt-get install --install-recommends webmin usermin
确认写入的源文件:
cat /etc/apt/sources.list.d/webmin-stable.list
deb [signed-by=/usr/share/keyrings/ubuntu-webmin-developers.gpg] https://download.webmin.com/download/newkey/repository stable contrib
刷新索引并确认候选版本:
apt-get update
Hit:5 https://download.webmin.com/download/newkey/repository stable InRelease
Reading package lists...
(实测为五条源命中回显之一节选,Webmin 源位于列表末行。)
apt-cache policy webmin
webmin:
Installed: (none)
Candidate: 2.670
Version table:
2.670 500
500 https://download.webmin.com/download/newkey/repository stable/contrib amd64 Packages
500 https://download.webmin.com/download/newkey/repository stable/contrib all Packages
验证通过:候选版本即官方源提供的 2.670。
4.3 安装 Webmin
apt-get install webmin --install-recommends
实测回显(输出过长,节选首尾):
Reading package lists...
Building dependency tree...
Reading state information...
Recommended packages:
libdbd-mariadb-perl
The following NEW packages will be installed:
webmin
0 upgraded, 1 newly installed, 0 to remove and 3 not upgraded.
Need to get 28.1 MB of archives.
After this operation, 163 MB of additional disk space will be used.
Get:1 https://download.webmin.com/download/newkey/repository stable/contrib amd64 webmin all 2.670 [28.1 MB]
Fetched 28.1 MB in 6s (4668 kB/s)
......
Selecting previously unselected package webmin.
(Reading database ... 13017 files and directories currently installed.)
Preparing to unpack .../archives/webmin_2.670_all.deb ...
Unpacking webmin (2.670) ...
Setting up webmin (2.670) ...
安装器会自动安装 Perl 及其依赖库(libnet-ssleay、libauthen-pam、libdbi-perl、libjson-xs 等),并完成 systemd 单元注册。
4.4 初始化 root 登录密码
Webmin 默认使用系统 root 账号登录(认证读 /etc/shadow)。若系统 root 未设密码(如 Ubuntu 默认锁定 root),用 Webmin 自带工具为其设置登录口令(本指南示例统一使用 root / q1w2e3r4,生产环境请使用强口令):
/usr/share/webmin/changepass.pl /etc/webmin root q1w2e3r4
Password for Webmin user root updated successfully
4.5 systemd 托管与验证
查看服务状态:
systemctl status webmin --no-pager
● webmin.service - Webmin server daemon
Loaded: loaded (/lib/systemd/system/webmin.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2026-10-21 06:57:46 UTC; 5s ago
Main PID: 4600 (miniserv.pl)
Tasks: 5 (limit: 94371)
Memory: 129.5M
CPU: 1.262s
CGroup: /system.slice/webmin.service
├─4600 /usr/bin/perl /usr/share/webmin/miniserv.pl --nofork /etc/webmin/miniserv.conf
├─4613 /usr/bin/perl /usr/share/webmin/miniserv.pl --nofork /etc/webmin/miniserv.conf
└─4614 /usr/bin/perl /usr/share/webmin/webmincron/webmincron.pl
确认开机自启与运行状态:
systemctl is-enabled webmin
enabled
systemctl is-active webmin
active
确认监听端口:
ss -ltnp | grep 10000
LISTEN 0 4096 0.0.0.0:10000 0.0.0.0:* users:(("miniserv.pl",pid=4600,fd=5))
LISTEN 0 4096 [::]:10000 [::]:* users:(("miniserv.pl",pid=4600,fd=6))
Web 服务探测(自签名证书用 -k 跳过校验):
curl -sk https://localhost:10000/ | head -1
<!DOCTYPE html>
<html data-bgs="gainsboro" class="ui--html session_login"><head>
返回登录页 HTML 即服务就绪。浏览器访问 https://<服务器IP>:10000,接受自签名证书告警后,用 root / 安装时设置的口令登录。
systemd 单元文件内容(/lib/systemd/system/webmin.service,供排障时对照):
[Unit]
Description=Webmin server daemon
Wants=network-online.target
After=network.target network-online.target
[Service]
Type=simple
Environment="PERLLIB=/usr/share/webmin"
ExecStart=/usr/share/webmin/miniserv.pl --nofork /etc/webmin/miniserv.conf
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
RestartSec=2s
TimeoutStopSec=300s
[Install]
WantedBy=multi-user.target
五、离线安装方案(B:deb 包直装)
5.1 方案说明
适用于「服务器无外网、但能通过内网中转下载」的场景:在能上网的机器下载官方 deb 包,拷贝到目标服务器安装。deb 包把 Perl 系依赖声明为 Pre-Depends,直接 dpkg -i 在纯净系统上会报依赖错误,需用 apt 补齐(下文如实演示该过程)。
5.2 下载 deb 包
官方仓库 pool 中 deb 包的固定路径规则为:
https://download.webmin.com/download/newkey/repository/pool/contrib/w/webmin/webmin_<版本>_all.deb
wget https://download.webmin.com/download/newkey/repository/pool/contrib/w/webmin/webmin_2.670_all.deb
webmin_2.670_all.deb 100% 28.1M 4.7MB/s 0:06
确认包元数据:
ls -la webmin_2.670_all.deb && dpkg -I webmin_2.670_all.deb | head -6
-rw------- 1 root root 28094890 Sep 21 03:31 webmin_2.670_all.deb
new Debian package, version 2.0.
size 28094890 bytes: control archive=124840 bytes.
927 bytes, 23 lines conffiles
794 bytes, 23 lines control
5.3 安装与依赖修复
先看直接 dpkg -i 的行为(纯净 Ubuntu 22.04 实测):
dpkg -i webmin_2.670_all.deb
perl is not installed.
dpkg: error processing archive webmin_2.670_all.deb (--install):
pre-dependency problem - not installing webmin
Errors were encountered while processing:
webmin_2.670_all.deb
Webmin 把 perl 声明为 Pre-Depends,未装 perl 时 dpkg 拒绝安装。用 apt 装本地包并自动补齐依赖(注意传绝对路径,相对路径会被 apt 解析到当前目录之外导致找不到文件):
apt-get install -y -f /root/webmin_2.670_all.deb
Setting up webmin (2.670) ...
Processing triggers for libc-bin (2.35-0ubuntu3.15) ...
(输出过长,此处节选末尾两行;中间为 apt 自动安装的 perl 及依赖库清单。)
5.4 验证
systemctl is-active webmin
active
cat /usr/share/webmin/version
2.670
与方案 A 装出的系统完全一致(同一 deb 包,服务与目录布局相同)。
六、源码安装方案(C:tar.gz setup 脚本)
6.1 方案说明
tar.gz 方案把 Webmin 安装到自选目录(本示例用 /root/webmin-2.670),不依赖包管理器,适合无法接入 apt 源的环境或需要与系统包管理器隔离的部署。代价是升级要重跑 setup 脚本、卸载走自带 uninstall 脚本。
6.2 前置依赖
tar.gz 不含依赖解析,需先手工装齐 Perl 与核心模块:
apt-get install -y perl libnet-ssleay-perl libauthen-pam-perl libpam-runtime libio-pty-perl apt-show-versions
Setting up apt-show-versions (0.22.11ubuntu1) ...
Processing triggers for man-db (2.10.2-1) ...
(节选末尾;libnet-ssleay 提供 SSL 支持,libauthen-pam 提供 PAM 认证支持。)
6.3 下载与解包
cd /root && wget https://www.webmin.com/download/webmin-2.670.tar.gz
webmin-2.670.tar.gz 100% 37.2M 4.9MB/s 0:08
ls -la webmin-2.670.tar.gz
-rw------- 1 root root 38959343 Sep 21 04:17 webmin-2.670.tar.gz
gunzip -c webmin-2.670.tar.gz | tar xf -
6.4 运行 setup.sh
setup.sh 为交互式安装,逐题作答如下(问句原文摘自 setup 脚本,作答为实测值):
| 问句 | 实测作答 | 说明 |
|---|---|---|
Config file directory [/etc/webmin]: | /etc/webmin | 配置目录,保持默认 |
Log file directory [/var/webmin]: | /var/webmin | 日志目录,保持默认 |
Web server port (default 10000): | 10000 | 服务端口,保持默认 |
Login name (default admin): | root | 用系统 root 账号登录 |
Login password: | q1w2e3r4 | 示例口令,生产请用强口令 |
Password again: | q1w2e3r4 | 复核口令 |
Use SSL (y/n): | y | 启用 HTTPS |
Start Webmin at boot time (y/n): | y | 注册开机自启 |
💡 说明:当前版本的 setup 脚本不再询问 perl 路径(自动探测并在输出中打印
Perl seems to be installed ok),操作系统类型也按/etc/os-release自动识别后直接回显,无需作答。
执行命令(安装完成后脚本同款作答亦可用于重装/升级场景):
cd /root/webmin-2.670 && ./setup.sh
实测回显(首段问句前导文案 + 安装动作节选):
****************************************************************************
Welcome to the Webmin setup script, version 2.670
****************************************************************************
Webmin is a web-based interface that allows Unix-like operating
systems and common Unix services to be easily administered.
Installing Webmin in /root/webmin-2.670
......
Running postinstall scripts ..
.. done
Enabling background status collection ..
.. done
Attempting to start Webmin web server ..
.. done
****************************************************************************
Webmin has been installed and started successfully.
Since Webmin was installed outside the package manager, ensure the
following recommended Perl modules and packages are present:
Perl modules:
- DateTime, DateTime::Locale, DateTime::TimeZone, Data::Dumper,
- Digest::MD5, Digest::SHA, Encode::Detect, File::Basename,
- File::Path, Net::SSLeay, Time::HiRes, Time::Local, Time::Piece,
- Socket6, Sys::Syslog, JSON::XS, lib, open
Packages:
- openssl - Cryptography library with TLS implementation
- shared-mime-info - Shared MIME information database
- tar gzip unzip - File compression and packaging utilities
Use your web browser to go to the following URL and login
with the name and password you entered previously:
https://<服务器IP>:10000
脚本同时提示:非包管理器安装需自行保证上述 Perl 模块与系统包在场(Ubuntu 上按 6.2 装齐 apt 包即可覆盖绝大多数项)。
6.5 验证
tar 方案同样注册 systemd 服务(setup 脚本检测到 systemd 会写入 /lib/systemd/system/webmin.service):
systemctl is-active webmin
active
ss -ltn | grep 10000
LISTEN 0 4096 0.0.0.0:10000 0.0.0.0:*
curl -sk https://localhost:10000/ -o /dev/null -w "http=%{http_code}\n"
http=200
检查操作系统识别结果是否正确(Webmin 按发行版适配模块路径,识别错了会导致模块行为异常):
grep -E "os_type|os_version|real_os" /etc/webmin/config
os_type=debian-linux
os_version=13.0
real_os_type=Ubuntu Linux
real_os_version=22.04.5
七、方案对比与选择建议
| 维度 | A 官方 apt 仓库 | B deb 包直装 | C tar.gz 源码 |
|---|---|---|---|
| 是否需联网 | 装源时需,升级随 apt | 仅中转机需 | 下载时需 |
| 依赖处理 | 自动 | apt 自动补齐 | 手工装齐 |
| 升级方式 | apt upgrade 随系统升级 | 重新下载新 deb 安装 | 重跑新版本 setup.sh |
| 服务托管 | systemd(自动注册) | systemd(自动注册) | systemd(setup 自动注册) |
| 程序路径 | /usr/share/webmin | /usr/share/webmin | /root/webmin-2.670(自选) |
| 卸载方式 | apt remove --purge webmin | 同左 | /etc/webmin/uninstall.sh |
| 适用场景 | 常规在线服务器(推荐) | 内网离线服务器 | 无包管理器/需多版本共存 |
选择建议:能联网选 A;内网隔离用 B(中转机下载 deb);需要把 Webmin 装进自定义目录、或与系统包管理器完全隔离时选 C。
八、安装后基础配置说明
8.1 配置文件布局
三种方案的配置布局一致:
/etc/webmin/ 全部配置:miniserv.conf(服务核心)、config(全局)、各模块同名子目录
/var/webmin/ 运行时:miniserv.log、miniserv.error、webmin.log、会话库
/usr/share/webmin/ 程序与模块脚本(tar 方案在安装目录下)
备份这两棵目录(/etc/webmin + /var/webmin)即可整体带走 Webmin 配置与审计日志。
8.2 修改监听端口
用官方 CLI 同时修改 port 与 listen 两个键(缺一不可),命令会自动重启服务使配置生效:
/usr/share/webmin/bin/webmin set-config --option port --value 10001
Restarting Webmin to apply miniserv.conf changes...
/usr/share/webmin/bin/webmin set-config --option listen --value 10001
Restarting Webmin to apply miniserv.conf changes...
ss -ltn | grep -E ":1000[01]"
LISTEN 0 4096 0.0.0.0:10001 0.0.0.0:*
curl -sk https://localhost:10001/ -o /dev/null -w "http=%{http_code}\n"
http=200
改回默认端口的方法相同(--value 10000 后实测监听回到 10000、HTTP 200)。
8.3 升级与版本管理
仓库方案(A/B)随系统升级即可:
apt-get update && apt-get install --only-upgrade webmin
当前候选版本即最新稳定版时的实测策略确认:
apt-cache policy webmin | head -4
webmin:
Installed: 2.670
Candidate: 2.670
Version table:
*** 2.670 500
两点实测结论:
- 官方 stable 源只保留最新版本的 deb(实测
webmin_2.660_all.deb、webmin_2.650_all.deb的 pool 路径均返回 HTTP 404),因此 apt 仓库方案不存在原地降级路径; - 需要旧版本时,从官方下载页取对应版本的 tar.gz 装到独立目录与现有版本并存,或提前自存历史 deb 包再用
apt-get install ./webmin_<旧版>_all.deb强制降级。
tar 方案(C)升级 = 下载新版本 tar.gz 解压到原目录(或新目录)后重跑 ./setup.sh,脚本检测到既有配置会自动执行升级流程并保留配置,实测回显末段:
Updating config files ..
.. done
Creating uninstall script /etc/webmin/uninstall.sh ..
.. done
Changing ownership and permissions ..
.. done
Running postinstall scripts ..
.. done
Attempting to restart Webmin web server ..
.. done
****************************************************************************
Webmin has been upgraded and restarted successfully.
九、常见问题(FAQ)
Q1:dpkg -i webmin_2.670_all.deb 报 pre-dependency problem - not installing webmin?
Webmin 的 deb 把 perl 声明为 Pre-Depends(解包前必须满足)。纯净系统直接 dpkg 必然失败,属预期行为。解决:改用 apt-get install -y -f /root/webmin_2.670_all.deb(注意绝对路径),apt 会先装 perl 及全部依赖再安装 Webmin。实测排障过程见 5.3 节。
Q2:登录页反复提示失败,错误日志出现 Cache issue or no cookies support?
这是 MiniServ 对「POST 登录请求未携带合法会话 Cookie」的标准报错(实测 miniserv.error 原文):
[21/Oct/2026:07:06:24 +0000] [127.0.0.1] /session_login.cgi : Cache issue or no cookies support : Please clear your browser's cache for the given domain and/or try incognito tab; double check to have cookies support enabled.
定位与解决:按提示清除浏览器缓存或改用无痕窗口,确认浏览器未禁用 Cookie;用脚本/爬虫调登录接口时必须先 GET 登录页取得会话 Cookie 再 POST 凭据。
Q3:多次输错密码后提示 too many authentication failures.?
这是内置防爆破机制生效(miniserv.conf 中 blockhost_failures=5、blockhost_time=60:60 秒内同来源失败 5 次即封锁该 IP)。实测第 1~4 次失败返回 Login failed. Please try again.,第 5 次直接返回 too many authentication failures.。等待 blockhost_time 秒后自动解封,或由 root 检查 /var/webmin/blocked/ 目录。
Q4:浏览器访问 https://<服务器IP>:10000 无响应?
按序排查:① systemctl is-active webmin 确认服务 active;② ss -ltnp | grep 10000 确认监听;③ 检查 UFW/安全组是否放行 10000/tcp;④ 若改过端口,确认访问的是 port/listen 的当前值(两键用 webmin list-config miniserv.conf 查看)。
Q5:curl https://localhost:10000 报证书错误?
Webmin 使用自签名证书(仅加密、无 CA 背书,官方安装页亦明示)。脚本探测用 -k 跳过;浏览器首次访问点「接受风险并继续」即可。生产如需正规证书,可用 Webmin 内置 Let's Encrypt 客户端或反向代理终结 TLS。
十、卸载与清理
10.1 卸载 apt/deb 方案
apt-get remove --purge -y webmin
After this operation, 163 MB disk space will be freed.
(Reading database ... 35340 files and directories currently installed.)
Removing webmin (2.670) ...
(Reading database ... 12747 files and directories currently installed.)
Purging configuration files for webmin (2.670) ...
卸载后确认服务已不存在:
systemctl is-active webmin
failed
(failed 说明单元已随包移除、进程已终止;顺带可清理 apt 源文件 /etc/apt/sources.list.d/webmin-stable.list 与密钥 /usr/share/keyrings/ubuntu-webmin-developers.gpg。)
10.2 卸载 tar.gz 方案
tar 方案自带交互卸载脚本,确认后依次停服务、删除程序目录/配置目录/日志目录:
/etc/webmin/uninstall.sh
脚本实际动作(内容摘自 /etc/webmin/uninstall.sh):提示 Are you sure you want to uninstall Webmin? (y/n) :,答 y 后执行 /etc/webmin/stop,再依次删除安装目录(如 /root/webmin-2.670)、/etc/webmin、/var/webmin,最后输出 Done!。
十一、参考链接
- Webmin 官方下载页(仓库配置脚本与各系统安装命令):https://www.webmin.com/download.html
- 官方 GitHub 仓库(Releases 页核对版本):https://github.com/webmin/webmin
- 官方文档站:https://doxfer.webmin.com/Webmin/Main_Page
- Webmin 当前版本配置参数的逐项说明见本专栏《Webmin 2.670 配置参数详解》篇;命令行工具用法见《Webmin 2.670 常用 CLI 命令与工具详解》篇。
- 本专栏系列:《Webmin 介绍与选型指南》。