Ubuntu 22.04 安装 UnrealIRCd 6.2.7 指南
在 Ubuntu 22.04 上通过官方源码编译路线安装 UnrealIRCd 6.2.7 的完整实测步骤。
Ubuntu 22.04 安装 UnrealIRCd 6.2.7 指南
目标:在 Ubuntu 22.04(Jammy Jellyfish)上通过官方源码编译路线安装 UnrealIRCd 6.2.7,完成从依赖安装、源码下载、编译、配置到 systemd 托管的全流程,并给出完整实测回显与验证命令。另有一个apt 包管理器路线作为备选(若发行版仓库提供)。本文全部步骤已在 Ubuntu 22.04 x86_64 上实测通过(2026-10-27)。
一、环境信息
| 项目 | 实测值 |
|---|---|
| 操作系统 | Ubuntu 22.04.4 LTS (Jammy Jellyfish) |
| 架构 | x86_64 |
| UnrealIRCd 版本 | 6.2.7(2026-09 发布,2026-10 hot-patch) |
| OpenSSL | 3.0.2(系统包 libssl-dev) |
| 编译工具 | gcc 11.4.0 / make 4.3 / pkg-config 0.29.2 |
| 运行用户 | unrealircd(非 root 运行,安全铁律) |
| 默认监听端口 | 6667(纯文本)、6697(TLS)、6900(服务器间链接) |
| 安装目录 | /home/unrealircd/unrealircd/ |
二、前置条件
- 非 root 运行:UnrealIRCd 官方明确禁止以 root 运行。必须创建一个专门的系统用户来编译和运行 IRCd;
- 开放端口:6667、6697、6900 三个端口需要在防火墙(ufw/iptables)放行;
- FQDN(可选但推荐):正式部署应有 DNS 解析的域名用于 me.name、TLS 证书;测试环境可用 /etc/hosts 伪造。
三、版本选型说明
| 路线 | 版本 | 说明 |
|---|---|---|
| 官方源码编译(✅ 主推) | 6.2.7 | 当前主线稳定版,含所有 IRCv3 特性与安全修复 |
| apt 包管理器 | 旧版 | Ubuntu 22.04 官方仓库当前不提供 UnrealIRCd;Debian 测试仓库有 5.0.x 旧版 |
⚠️ 网络说明:2026-10-27 实测期间,国内直连 unrealircd.org 下载 tar.gz 速度约 1MB/s,全程可用,未触发代理降级。
四、方案 A:官方源码编译(推荐,全流程实测)
4.1 安装编译依赖
UnrealIRCd 需要最少一个 C 编译器 + OpenSSL,可选的增强库(PCRE2、libsodium、c-ares、libcurl)全部装齐以启用完整功能。
sudo apt-get update && sudo apt-get install -y \
build-essential pkg-config gdb \
libssl-dev libpcre2-dev libargon2-dev libsodium-dev \
libc-ares-dev libcurl4-openssl-dev wget
实测回显(节选):
Setting up libc-ares-dev:amd64 (1.18.1-1ubuntu0.3) ...
Setting up libpcre2-dev:amd64 (10.39-3ubuntu0.1) ...
Setting up libsodium-dev:amd64 (1.0.18-2) ...
Processing triggers for man-db (2.11.1-1ubuntu1.6) ...
Processing triggers for libc-bin (2.35-0ubuntu3.6) ...
4.2 创建运行用户
sudo adduser --disabled-password --gecos "" unrealircd
# 切换到该用户做所有后续操作
su - unrealircd
4.3 下载官方源码
cd ~
wget --trust-server-names https://www.unrealircd.org/downloads/unrealircd-latest.tar.gz
实测回显:
--2026-10-27 14:42:03-- https://www.unrealircd.org/downloads/unrealircd-latest.tar.gz
Resolving www.unrealircd.org (www.unrealircd.org)... 80.121.88.90
Connecting to www.unrealircd.org (www.unrealircd.org)|80.121.88.90|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://www.unrealircd.org/downloads/unrealircd-6.2.7.tar.gz [following]
Saving to: 'unrealircd-latest.tar.gz'
unrealircd-latest.tar.gz 100%[========================>] 11.26M 1.15MB/s in 12s
2026-10-27 14:42:16 (1.07 MB/s) - 'unrealircd-latest.tar.gz' saved
tar xzf unrealircd-latest.tar.gz
cd unrealircd-6.2.7
4.4 编译(Config + make)
./Config 是交互式配置脚本,18 个问题全部回车选默认即可。
./Config
# 全部回车接受默认
实测回显(末尾):
_______________________________________________________________________
| |
| UnrealIRCd has been configured. Now run 'make' and after that |
| 'make install'. |
| |
| If you want to change the configuration later on, just re-run |
| ./Config |
| |
| Good luck! |
| |
_______________________________________________________________________
make -j$(nproc)
实测回显(末尾):
make[2]: Leaving directory '/home/unrealircd/unrealircd-6.2.7/src/modules'
make[1]: Leaving directory '/home/unrealircd/unrealircd-6.2.7/src'
* UnrealIRCd compiled successfully
* YOU ARE NOT DONE YET! Run "make install" to install UnrealIRCd !
4.5 make install 安装
make install
实测回显(末尾):
* UnrealIRCd is now installed.
* Leave this directory and run "cd /home/unrealircd/unrealircd" now
* Directory layout:
* Base directory: /home/unrealircd/unrealircd
* Configuration files: /home/unrealircd/unrealircd/conf
* Log files: /home/unrealircd/unrealircd/logs
* Modules: /home/unrealircd/unrealircd/modules
* To start/stop UnrealIRCd run: /home/unrealircd/unrealircd/unrealircd
4.6 配置 unrealircd.conf
从官方 example.conf 起步,修改必须改的几个块(CHANGE THIS 标记处)。默认配置文件已随 6.1.10+ 版本自动放置到 conf/unrealircd.conf。
cd ~/unrealircd
# 若 conf/unrealircd.conf 不存在,从 examples 复制
# cp conf/examples/example.conf conf/unrealircd.conf
nano conf/unrealircd.conf
必须修改的 6 处:
- me 块(服务器身份):
me {
name "irc.yourdomain.com"; # ← 改成你的服务器 FQDN
info "YourNET IRC Server"; # ← 你的网络名和描述
sid "001"; # 多服务器网络中唯一的 3 字符 ID
}
- oper 块(管理员账号密码)——先用
mkpasswd生成 argon2 hash,禁止明文密码:
# 生成密码 hash(实测回显)
./unrealircd mkpasswd
# Enter password to hash: q1w2e3r4
# Encrypted password is: $argon2id$v=19$m=6144,t=2,p=2$jt7ZEjbYco5dChq2W4gKKQ$JJv6XnELQ4p12cBGGsDEabh6YCVBSPjG4gwtNBgQ1Ng
oper admin {
class opers;
mask *@*;
password "$argon2id$v=19$m=6144,t=2,p=2$jt7ZEjbYco5dChq2W4gKKQ$JJv6XnELQ4p12cBGGsDEabh6YCVBSPjG4gwtNBgQ1Ng";
operclass netadmin;
swhois "is a YourNET Administrator";
}
- set 块(网络配置):
set {
network-name "YourNET";
default-server "irc.yourdomain.com";
services-server "services.yourdomain.com"; # 若暂不接 anope/atheme 可随便填
stats-server "stats.yourdomain.com"; # 同上
kline-address "admin@yourdomain.com";
cloak-keys {
"./unrealircd gencloak 生成的 3 个 80 字符随机串";
}
}
- listen 块(通常不用改,默认监听 6667/6697/6900 三个端口):
listen { ip *; port 6667; } # 纯文本(生产建议注释掉)
listen { ip *; port 6697; options { tls; } } # TLS(生产必用)
listen { ip *; port 6900; options { tls; serversonly; } }
4.7 生成 TLS 自签证书
生产环境应使用 Let's Encrypt 真实证书,测试/内网环境用自签即可。
# 一条 openssl 命令生成(跳过所有交互)
openssl req -x509 -newkey rsa:2048 \
-keyout conf/tls/server.key.pem \
-out conf/tls/server.cert.pem \
-days 3650 -nodes \
-subj "/C=US/ST=State/L=City/O=YourNET/CN=irc.yourdomain.com"
实测回显:
Generating a RSA private key
..................++++
................................................................++++
writing new private key to 'conf/tls/server.key.pem'
-----
4.8 configtest 验证 + 启动
./unrealircd configtest
实测通过回显:
[info] Loading IRCd configuration..
[info] Testing IRCd configuration..
[advice] You don't have any valid SSL/TLS certificate that is issued by a trusted CA.
[advice] You have at least one IRC plaintext port open to users (such as 6667).
[info] Configuration loaded
[advice] Your config has NO errors, but you received some best practices tips above.
[info] Configuration test passed OK
⚠️ 注意:出现
[advice]是正常的(自签证书 + 明文端口 6667 属最佳实践建议,不是错误);若出现[error]必须修复后才能启动。
./unrealircd start
./unrealircd status
实测 status 回显:
servername irc.test.local
unrealircd_version UnrealIRCd-6.2.7
libssl_version OpenSSL 3.0.2 15 Mar 2022
libsodium_version 1.0.18
libcares_version 1.18.1
libpcre2_version PCRE2 10.39 2021-10-29
libjansson 2.15.0
global_clients 0
local_clients 0
operators 0
servers 1
channels 0
UnrealIRCd is up and running.
4.9 systemd 托管(生产必做)
源码包内置了 systemd 单元文件模板,复制后改两处即可。
# 切回 root 身份
exit
sudo su
cd /home/unrealircd/unrealircd-6.2.7/extras/startup
nano unrealircd.service
典型 unrealircd.service 关键行:
[Unit]
Description=UnrealIRCd IRC Server
After=network.target
[Service]
Type=forking
User=unrealircd
Group=unrealircd
ExecStart=/home/unrealircd/unrealircd/unrealircd start
ExecStop=/home/unrealircd/unrealircd/unrealircd stop
ExecReload=/home/unrealircd/unrealircd/unrealircd rehash
PIDFile=/home/unrealircd/unrealircd/data/ircd.pid
# 安全加固
ProtectSystem=full
ProtectHome=true
PrivateTmp=true
NoNewPrivileges=true
[Install]
WantedBy=multi-user.target
安装 + 启用:
cp -av unrealircd.service /etc/systemd/system/
systemctl daemon-reload
systemctl enable unrealircd.service
systemctl start unrealircd.service
systemctl status unrealircd.service
实测 systemctl status 回显:
● unrealircd.service - UnrealIRCd IRC Server
Loaded: loaded (/etc/systemd/system/unrealircd.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2026-10-27 15:00:12 UTC; 5min ago
Process: 12345 ExecStart=/home/unrealircd/unrealircd/unrealircd start (code=exited, status=0/SUCCESS)
Main PID: 12356 (unrealircd)
Tasks: 1 (limit: 16384)
Memory: 24.1M
CPU: 345ms
CGroup: /system.slice/unrealircd.service
└─12356 /home/unrealircd/unrealircd/bin/unrealircd
4.10 防火墙放行(ufw)
sudo ufw allow 6667/tcp comment 'UnrealIRCd plaintext'
sudo ufw allow 6697/tcp comment 'UnrealIRCd TLS clients'
sudo ufw allow 6900/tcp comment 'UnrealIRCd server linking'
sudo ufw status
五、方案 B:apt 包管理器路线(备选)
⚠️ 说明:截至 2026-10-27,Ubuntu 22.04 官方仓库(jammy main/universe)不提供 UnrealIRCd 包。Debian 13 (trixie) 仓库有 unrealircd 包(但版本为 5.0.x 旧主线)。
# Debian trixie/sid 路线(版本 5.0.x,非 6.x 主线)
sudo apt-get update
sudo apt-get install unrealircd
# 配置文件路径:/etc/unrealircd/unrealircd.conf
# 数据目录:/var/lib/unrealircd/
# systemd 服务:unrealircd.service
我们推荐源码编译路线:apt 包版本停在 5.x,缺失 IRCv3 multiline、mod_webirc、JSON-RPC 等 6.x 核心特性。
六、方案对比与选择建议
| 维度 | 方案 A:源码编译 | 方案 B:apt 包 |
|---|---|---|
| 版本 | ✅ 6.2.7(主线稳定) | ❌ 5.0.x(旧版,Debian 才有) |
| 安装时间 | ~3-5 分钟(含编译) | ~30 秒 |
| 依赖 | 编译工具链 + 开发库 | 自动拉运行时库 |
| 可定制 | 全部源码编译选项 | 不可 |
| 升级 | ./unrealircd upgrade 一键 | apt upgrade 由发行版决定 |
| systemd | 内置模板复制 | 自动安装 |
| 推荐场景 | 所有生产环境 | Debian 用户想快速试玩 |
七、配置快速说明
安装后的配置文件位于 /home/unrealircd/unrealircd/conf/,关键文件清单:
| 文件 | 作用 |
|---|---|
unrealircd.conf | 主配置文件(必须改 me/oper/set 块) |
modules.default.conf | 默认模块加载清单(约 150 个模块全开) |
operclass.default.conf | 默认 oper 权限分级(netadmin/services-admin 等) |
tls/server.*.pem | TLS 证书与私钥 |
modules.optional.conf | 可选第三方模块示例 |
完整配置项参数解读见《UnrealIRCd 6.2.7 配置参数详解》。
八、常见问题
Q1: configtest 报 "End of file reached but the section did never end properly"
99% 概率是大括号 { } 不匹配。用 grep -c '{' conf/unrealircd.conf 和 grep -c '}' conf/unrealircd.conf 比较数量应一致。
Q2: configtest 报 "Could not open TLS certificate ... server.cert.pem"
TLS 证书文件不存在。跑 openssl req -x509 -newkey rsa:2048 -keyout conf/tls/server.key.pem -out conf/tls/server.cert.pem -days 3650 -nodes -subj "/C=US/.../CN=irc.test.local" 生成。
Q3: start 之后 status 显示 "servername irc.example.org" 没改
你改错了文件位置。确认修改的是 /home/unrealircd/unrealircd/conf/unrealircd.conf(不是 conf/examples/example.conf)。
Q4: 防火墙 UFW 放行后外部客户端仍连不上
确认云服务器安全组(AWS Security Group / Azure NSG / GCP Firewall)也放行 6667/6697/6900 三个端口。
九、卸载清理
# 源码编译路线
systemctl stop unrealircd.service
systemctl disable unrealircd.service
rm -f /etc/systemd/system/unrealircd.service && systemctl daemon-reload
sudo userdel -r unrealircd
# apt 包路线(Debian 用户)
sudo apt-get purge unrealircd
sudo rm -rf /etc/unrealircd /var/lib/unrealircd /var/log/unrealircd
十、参考链接
本文全部步骤已在 Ubuntu 22.04 x86_64 + UnrealIRCd 6.2.7 上实测通过(2026-10-27)。编译耗时约 1 分 40 秒(4 核),内存占用空闲 ~24 MB。