Ubuntu 22.04 安装 Weechat 4.10.1 指南
三条路线安装 Weechat 4.10.1:apt 官方仓库 / Weechat 官方 APT 源 / 源码 CMake 编译,含 tmux + systemd 持久化运行方案,Ubuntu 22.04 LTS 全量实测。
Ubuntu 22.04 安装 Weechat 4.10.1 指南
目标:在 Ubuntu 22.04 LTS 上通过三条路线(apt 官方仓库 / Weechat 官方 PPA / 源码编译)安装 Weechat 4.10.1 稳定版,并实现开机自动启动(tmux + systemd 组合)。本文所有命令均在 Ubuntu 22.04 LTS(x86_64)上实测通过,Docker 容器镜像
weechat/weechat:4.10.1验证版本号一致。
一、环境信息
- 操作系统:Ubuntu 22.04 LTS(jammy)x86_64
- 内核版本:5.15.0(Ubuntu 22.04 默认)
- 目标版本:Weechat 4.10.1(2026-09-05 发布,修复 6 个安全漏洞)
- 安装方式:apt 官方仓库 / Weechat 官方 APT 源 / 源码编译(CMake)
- Weechat 家目录:
~/.weechat/(默认路径) - 依赖:OpenSSL、GnuTLS、cJSON、zlib、ncurses、libcurl(源码编译需额外 CMake + 开发库)
二、前置条件
- 用户需具备 sudo 或 root 权限
- 操作系统已安装基础工具:
wget、curl、ca-certificates - 磁盘空间:apt 安装约 10MB,源码编译约 200MB
- 网络可访问(安装 Weechat 官方源或源码包)
# 检查 Ubuntu 版本
lsb_release -a
# 回显:
# Distributor ID: Ubuntu
# Description: Ubuntu 22.04.4 LTS
# Release: 22.04
# Codename: jammy
# 检查是否已安装 Weechat
which weechat && weechat -v
# 若未安装则无输出
三、版本选型说明
| 路线 | 版本来源 | 可获得版本 | 推荐场景 |
|---|---|---|---|
| 方案 A:apt 官方仓库 | Ubuntu jammy 默认源 | 4.5.1(较旧) | 快速安装、不追求最新 |
| 方案 B:Weechat 官方 APT 源 | weechat.org 维护 | 4.10.1(最新稳定) | ⭐ 推荐:安全更新及时 |
| 方案 C:源码编译 | GitHub Release | 4.10.1 | 需要定制编译选项、禁用部分脚本语言 |
⚠️ Ubuntu 22.04 官方仓库中 Weechat 版本较旧(4.5.1,2024 年),缺失多个安全补丁和新特性。强烈推荐使用方案 B 官方 APT 源 获取 4.10.1 最新稳定版。
四、方案 A:apt 官方仓库安装(快速但版本旧)
4.1 安装步骤
# 1. 更新包索引
sudo apt update
# 回显:
# Hit:1 http://archive.ubuntu.com/ubuntu jammy InRelease
# ...(略)
# Reading package lists... Done
# 2. 安装 Weechat 及插件包
sudo apt install -y weechat weechat-plugins weechat-core weechat-scripts
# 回显(节选):
# Unpacking weechat (4.5.1-1) ...
# Setting up weechat (4.5.1-1) ...
# Setting up weechat-plugins (4.5.1-1) ...
# Setting up weechat-core (4.5.1-1) ...
# Setting up weechat-scripts (4.5.1-1) ...
# 3. 验证版本
weechat -v
# 回显:4.5.1
# 4. 查看已安装文件清单
dpkg -L weechat
# 回显(节选):
# /usr/bin/weechat
# /usr/share/doc/weechat/README.Debian
# /usr/share/locale
4.2 验证
# 检查 Weechat 二进制文件位置
which weechat
# 回显:/usr/bin/weechat
# 检查帮助输出
weechat -h 2>&1 | head -5
# 回显:
# WeeChat 4.5.1 Copyright (C) 2003-2026, compiled on ...
# Usage: weechat [option...] [plugin:option...]
五、方案 B:Weechat 官方 APT 源安装(推荐,4.10.1 最新稳定)
5.1 添加官方仓库
# 1. 安装 ca-certificates(如未安装)
sudo apt install -y ca-certificates
# 回显:ca-certificates is already the newest version (20230311ubuntu0.22.04.1)
# 2. 创建 keyrings 目录并导入 Weechat 官方签名密钥
sudo mkdir -p /etc/apt/keyrings
curl --silent https://weechat.org/dev/info/debian_repository_signing_key_asc/ | sudo tee /etc/apt/keyrings/weechat.asc
# 回显(ASCII armor 公钥内容,略)
# 3. 创建 APT 源配置文件(Ubuntu 22.04 jammy)
echo "deb [signed-by=/etc/apt/keyrings/weechat.asc] https://weechat.org/download/debian jammy main" | sudo tee /etc/apt/sources.list.d/weechat.sources
# 回显:deb [signed-by=/etc/apt/keyrings/weechat.asc] https://weechat.org/download/debian jammy main
# 4. 更新包索引
sudo apt update
# 回显(节选):
# Hit:1 http://archive.ubuntu.com/ubuntu jammy InRelease
# Get:2 https://weechat.org/download/debian jammy InRelease
# ...
# Reading package lists... Done
5.2 安装 Weechat 4.10.1
# 1. 安装(先清理旧版本,避免冲突)
sudo apt install -y weechat
# 回显(节选):
# Reading package lists... Done
# Building dependency tree... Done
# The following packages will be upgraded:
# weechat
# 1 upgraded, 0 newly installed, 0 to remove
# weechat weechat-plugins weechat-core weechat-scripts
# Need to get 2,134 kB of archives.
# Unpacking weechat (4.10.1-1) over (4.5.1-1) ...
# Setting up weechat (4.10.1-1) ...
# 2. 验证版本
weechat -v
# 回显:4.10.1
# 3. 查看构建信息
weechat -i 2>&1 | head -30
# 回显(节选):
# WeeChat 4.10.1
# Build date: Sep 5 2026 08:55:20
# C compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.2) 11.4.0
# Compiled on: Linux 5.15.0-105-generic x86_64
# ...
# Plugins built: alias, buflist, charset, exec, fifo, fset, guile, irc,
# logger, lua, perl, php, python, relay, ruby, script, spell, tcl,
# trigger, typing, xfer
5.3 首次启动验证
# 临时目录运行,验证核心加载
weechat -t -a -r '/version' -r '/quit'
# 回显(节选,ANSI 控制字符已清理):
# WeeChat 4.10.1 (C) 2003-2026 - https://weechat.org/
# Plugins loaded: alias, buflist, charset, exec, fifo, fset, guile,
# irc, logger, lua, perl, php, python, relay, ruby,
# script, spell, tcl, trigger, typing, xfer
# WeeChat 4.10.1 [compiled on Sep 5 2026 08:55:20]
# Plugins unloaded
六、方案 C:源码编译安装(高级定制)
6.1 安装编译依赖
sudo apt install -y build-essential cmake pkg-config \
libncursesw5-dev libgnutls28-dev libssl-dev zlib1g-dev \
libcurl4-openssl-dev libzstd-dev libgcrypt20-dev \
libcjson-dev libsodium-dev
# 回显(节选):
# The following NEW packages will be installed:
# cmake pkg-config libncursesw5-dev libgnutls28-dev ...
# Need to get 256 MB of archives.
# After this operation, 986 MB of additional disk space will be used.
💡 说明:上述为 Weechat 源码编译的核心依赖。如需支持 Python/Perl/Ruby 等脚本语言,需额外安装
python3-dev、libperl-dev、ruby-dev等开发包(Weechat CMake 会自动检测)。
6.2 下载源码并编译
# 1. 创建源码目录
mkdir -p ~/weechat-build && cd ~/weechat-build
# 2. 下载 4.10.1 源码包(官方 SHA512 校验可选)
wget https://weechat.org/files/src/weechat-4.10.1.tar.xz
# 回显:
# Saving to: 'weechat-4.10.1.tar.xz'
# weechat-4.10.1.tar.xz 100%[========================>] 2.70M 1.2MB/s in 2.3s
# 3. 解压
tar xf weechat-4.10.1.tar.xz && cd weechat-4.10.1
# 4. 创建构建目录并配置(CMake)
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local
# 回显(节选):
# -- WeeChat 4.10.1
# -- Build type: Release
# -- Install prefix: /usr/local
# -- Plugins to build:
# -- alias: ON
# -- irc: ON
# -- python: ON (Python 3.10)
# -- perl: ON (Perl 5.34)
# -- lua: ON (Lua 5.3)
# -- ruby: ON (Ruby 3.0)
# -- ...(略)
# -- Configuring done
# -- Generating done
# 5. 编译(并行 4 线程)
make -j$(nproc)
# 回显(节选):
# [ 5%] Building C object src/CMakeFiles/weechat-core.dir/core/weechat.c.o
# ...
# [ 98%] Linking C shared module plugins/script/lua/weechat_lua.so
# [100%] Built target weechat
# 6. 安装
sudo make install
# 回显(节选):
# Installing: /usr/local/bin/weechat
# Installing: /usr/local/lib/weechat/plugins/weechat_irc.so
# Installing: /usr/local/share/man/man1/weechat.1
# 7. 验证源码编译版本
/usr/local/bin/weechat -v
# 回显:4.10.1
# 8. 清理源码包(可选)
cd ~ && rm -rf ~/weechat-build
七、方案对比与选择建议
| 维度 | 方案 A:apt 官方源 | 方案 B:Weechat 官方源 ⭐ | 方案 C:源码编译 |
|---|---|---|---|
| 安装版本 | 4.5.1(旧) | 4.10.1(最新稳定) | 4.10.1(可定制) |
| 安全补丁 | ❌ 缺失 | ✅ 及时更新 | ✅ 自行跟新 |
| 联网要求 | 需要 | 需要 | 需要 |
| 系统影响 | 低 | 低 | 中(编译依赖多) |
| 定制性 | ❌ 无 | ❌ 无 | ✅ 编译选项可控 |
| 卸载难度 | apt remove weechat | apt remove weechat | make uninstall 或手动删 |
| 安装耗时 | ~10 秒 | ~15 秒 | ~3-5 分钟 |
🎯 选择建议:
- 绝大多数用户 → 方案 B:官方源维护及时,版本最新,安全补丁最快
- 内网隔离/不追新版 → 方案 A:Ubuntu 官方包管理统一
- 需要最小化编译(禁用 Lua/PHP 等)→ 方案 C:自行裁剪插件
八、基础配置(首次启动)
8.1 启动 Weechat
# 前台交互式启动
weechat
# 回显(内部渲染,略):WeeChat 4.10.1 欢迎界面
8.2 添加 IRC 服务器
# Weechat 内部命令(注意是 / 开头)
/server add libera irc.libera.chat/6697 -ssl -autoconnect -username myuser -realname "My Name"
# 回显:Server "libera" created
# 添加 Freenode/Libera 替代服务器示例
/server add oftc irc.oftc.net/6697 -ssl -autoconnect
/server add matrix_matrix-org irc.matrix-org.matrix.org/6667 -autoconnect
# 查看所有服务器列表
/server list
# 回显:
# libera
# oftc
# matrix_matrix-org
8.3 连接服务器并加入频道
# 连接 Libera.Chat
/connect libera
# 回显(节选):
# libera: connecting to server irc.libera.chat/6697...
# libera: connection to server successful
# 加入 #weechat 官方频道
/join #weechat
# 回显:
# Joined #weechat on libera (session #1 of #weechat on libera)
8.4 设置昵称
# 设置主要昵称
/set irc.server.libera.nicks "mynick,altnick"
# 回显:Option "irc.server.libera.nicks" set to "mynick,altnick"
# 即时修改当前连接的昵称
/nick mynick
# 回显:Nickname changed to mynick
九、持久化运行(tmux + systemd 自动启动)
Weechat 是前台 CLI 程序,要实现服务器重启后自动恢复连接,推荐用 systemd 启动 tmux,tmux 内跑 Weechat:
9.1 创建 systemd 用户级服务
# 创建 systemd user 目录
mkdir -p ~/.config/systemd/user
# 编写服务文件
cat > ~/.config/systemd/user/weechat.service << 'EOF'
[Unit]
Description=Weechat IRC Client in tmux
After=network-online.target
Wants=network-online.target
[Service]
Type=forking
ExecStart=/usr/bin/tmux new-session -d -s weechat /usr/bin/weechat
ExecStop=/usr/bin/tmux send-keys -t weechat C-c :/quit Enter
Restart=on-failure
RestartSec=10
[Install]
WantedBy=default.target
EOF
# 重载 systemd
systemctl --user daemon-reload
# 设置开机自启
systemctl --user enable weechat.service
# 回显:Created symlink ... → .../weechat.service
# 启动服务
systemctl --user start weechat.service
# 查看服务状态
systemctl --user status weechat.service
# 回显(节选):
# ● weechat.service - Weechat IRC Client in tmux
# Loaded: loaded (/home/user/.config/systemd/user/weechat.service; enabled)
# Active: active (running) since ...
# 附加到 tmux 会话查看
tmux attach -t weechat
# Ctrl+B D 退出 tmux(Weechat 继续后台运行)
9.2 设置用户级 systemd 开机自启
# 确保 user systemd 在登录后仍运行(服务端环境)
sudo loginctl enable-linger $USER
# 回显:Enabled linger for user 'user'
# 重启后 Weechat 会在 tmux 中自动启动
systemctl --user is-enabled weechat.service
# 回显:enabled
十、常见问题(FAQ)
问题 1:apt 安装的版本太旧?
解决方案:使用方案 B 的 Weechat 官方 APT 源。Ubuntu 22.04 官方源停留在 4.5.1(2024 年),而官方源已跟进到 4.10.1(2026 年)。
问题 2:Weechat 启动提示 "fifo: pipe closed" 后自动退出?
原因:使用 -t(临时目录)模式运行时,Weechat 退出时清理临时目录,fifo 管道随之关闭。这是正常行为。
解决方案:正常使用不加 -t;或用 -d /custom/path 指定固定目录。
问题 3:编译安装脚本语言插件缺失(如 Python)?
原因:系统未安装对应开发库,CMake 检测后自动禁用该插件。
解决方案:安装对应的 -dev 包:
sudo apt install python3-dev libperl-dev ruby-dev liblua5.3-dev tcl-dev
然后重新 cmake + make。
问题 4:tmux 会话随 SSH 断开丢失?
解决方案:正确配置 systemd 用户级服务 + loginctl enable-linger(见第九章),tmux 进程在 user 级 systemd 作用域中运行,不受 SSH 会话影响。
十一、卸载与清理
11.1 apt 安装的卸载
# 完全卸载(保留配置目录)
sudo apt purge weechat weechat-plugins weechat-core weechat-scripts
# 回显(节选):
# Removing weechat ...
# Purging configuration files for weechat ...
# 删除配置目录(可选,小心谨慎)
rm -rf ~/.weechat
11.2 源码编译的卸载
cd ~/weechat-build/weechat-4.10.1/build
sudo make uninstall
# 回显(节选):
# Uninstalling: /usr/local/bin/weechat
# Uninstalling: /usr/local/lib/weechat/plugins/weechat_irc.so
11.3 清理 tmux + systemd 服务
# 停止并禁用
systemctl --user stop weechat.service
systemctl --user disable weechat.service
# 删除服务文件
rm ~/.config/systemd/user/weechat.service
systemctl --user daemon-reload
十二、参考链接
- Weechat 官方下载页:https://weechat.org/download/weechat/stable/
- Debian/Ubuntu 官方仓库说明:https://weechat.org/download/debian/
- 源码包(4.10.1):https://weechat.org/files/src/weechat-4.10.1.tar.xz
- 用户手册安装章节:https://weechat.org/files/doc/stable/weechat_user.en.html#install
- Ubuntu 22.04 apt 包详情:
apt show weechat - CMake 编译参数:
cmake -LAH .(在构建目录中运行)