iRedMail 1.8.8 Rocky Linux 9 安装指南

在 Rocky Linux 9 上从零安装 iRedMail 1.8.8 一键邮件服务器套件:FQDN 主机名、dnf 依赖准备、交互式向导逐屏实操、Postfix/Dovecot/Nginx/MariaDB 服务验证与 Web 入口登录,并实录 EPEL 仓库缺失、curl 冲突、安装状态残留三类真实排障。

iRedMailiRedMailRocky LinuxLinuxPostfixDovecot邮件服务器2026/10/17

iRedMail 1.8.8 Rocky Linux 9 安装指南

目标:在 Rocky Linux 9.8 上从零安装 iRedMail 1.8.8 全栈邮件服务器(Postfix + Dovecot + Nginx + MariaDB + Amavisd/SpamAssassin/ClamAV + Roundcube + iRedAdmin + Fail2ban + iRedAPD),逐屏实录交互向导,并沉淀本次实测踩到的 EPEL 仓库、curl 冲突、安装状态残留三处排障实录。

💡 技术拓展:一键邮件服务器套件横向对比(为何选 iRedMail)——

方案部署形态管理界面与本文场景的匹配
iRedMailBash 安装脚本装原生包,多发行版支持iRedAdmin + Roundcube原生 systemd 服务,支持 RHEL 系 9/10,本篇实测 Rocky 9.8
MailcowDocker Compose 容器全家桶SOGo + 内置 Admin依赖容器运行时,RHEL 系裸机原生服务党不宜
Mail-in-a-BoxUbuntu 专属脚本自带面板强绑定 Ubuntu,Rocky 不可用
ModoboaPython 安装器Django 面板组件重叠但社区规模较小,RHEL 系支持一般

关键差异:Rocky/RHEL 生态下 iRedMail 是社区方案里发行版适配最全的一个(1.8.8 官方支持 RHEL 9/10 系)。本文选 1.8.8 是因为它明确支持 Rocky Linux 9;Rocky Linux 8 已在 1.8.0 被官方移除支持(ChangeLog 实录见 2.1 节),因此本篇实测环境为 Rocky Linux 9.8 而非 8。

一、环境信息

  • 操作系统:Rocky Linux 9.8 (Blue Onyx),8 核 CPU / 7860 MB 内存
  • iRedMail 版本:1.8.8(2026-09-08 发布的官方最新稳定版),账号后端 MariaDB
  • 组件版本(rpm 实测):Postfix 3.5.25、Dovecot 2.3.16、MariaDB 10.5.29、Nginx 1.20.1、PHP 8.2(模块化 php-fpm);服务单元为 amavisd、clamd@amavisd
  • 域名与 IP:演示域 example.com,服务器 FQDN mail.example.com(/etc/hosts 以 127.0.0.1 演示映射)
  • 端口:25/587(SMTP/提交)、143/993(IMAP)、443(Web)、19999(netdata,监听 127.0.0.1)

二、版本与发行版选择

2.1 为什么是 Rocky Linux 9 + iRedMail 1.8.8

官方 1.8.8 安装包 ChangeLog(iRedMail-1.8.8/ChangeLog 实录)对支持的发行版有明确边界:

- Supports new distribution releases:
  + RHEL 9, Rocky Linux 9, AlmaLinux 9, CentOS Stream 9 and Oracle Linux 9.
  + Ubuntu 24.04 LTS.
  + Debian 13 (Trixie).
- Removed distribution releases which are end-of-life:
  + RHEL 8, Rocky Linux 8, AlmaLinux 8, CentOS Stream 8, Oracle Linux 8.
  + Ubuntu 20.04 LTS and Ubuntu 22.04 LTS.

据此得出两条硬结论:

  1. Rocky Linux 8 不在 1.8.x 支持列表(1.8.0 起移除),Rocky 8 用户只能退回 1.7.x 旧版或升级 Rocky 9;
  2. Rocky 9 的对应版本就是 1.8.8(官方最新稳定版,2026-09-08 发布,官网下载页确认)。

因此本篇实测发行版定为 Rocky Linux 9.8(Blue Onyx),组件版本实测清单:

$ cat /etc/rocky-release
Rocky Linux release 9.8 (Blue Onyx)

$ rpm -q postfix dovecot mariadb-server nginx php-common | head -5
postfix-3.5.25-3.el9_8.x86_64
dovecot-2.3.16-18.el9_8.8.x86_64
mariadb-server-10.5.29-3.el9_7.x86_64
nginx-1.20.1-28.el9_8.6.rocky.0.1.x86_64
php-common-8.2.33-1.module+el9.8.0+40305+0c876ebe.x86_64

⚠️ 标题说明:原计划标题为「Rocky Linux 8 安装指南」,实测前置检查发现 iRedMail 1.8.x 官方已明确移除 Rocky 8 支持(上文 ChangeLog),且 1.7.x 对 RHEL 系 8 的包源(EPEL 8 等)已过维护期;为保证全流程真实可复现,实测环境改用 Rocky Linux 9.8,标题随之调整。

2.2 硬件与网络要求

与 Ubuntu 版一致:最低 2 GB 内存,推荐 4 GB+(反垃圾杀毒栈吃内存)。本机实测(真实回显):

$ free -m
               total        used        free      shared  buff/cache   available
Mem:            7860         246        7250           2         364        7383

$ nproc
8

网络要求:需要访问 mirrors(Rocky BaseOS/AppStream/CRB/Extras)、dl.iredmail.org(组件包)与 GitHub(安装包)。生产外发需 25 端口出站可用;域内互发不依赖。

三、安装准备

3.1 设置 FQDN 主机名

hostnamectl set-hostname mail.example.com

实测回显:

$ hostname -f
mail.example.com

写入 hosts(本机演示用 127.0.0.1,生产改为真实 IP):

echo "127.0.0.1 mail.example.com mail" >> /etc/hosts

实测验证:

$ tail -1 /etc/hosts
127.0.0.1 mail.example.com mail

$ hostname -f
mail.example.com

3.2 下载 iRedMail 1.8.8 安装包

curl -LO https://github.com/iredmail/iRedMail/archive/refs/tags/1.8.8.tar.gz

实测回显(下载完成校验压缩包完整):

HTTP 200 size=250316B
t188-ok

⚠️ 排障实录:GitHub 直连受限时走代理——curl -x http://192.168.1.62:7897 -LO https://github.com/iredmail/iRedMail/archive/refs/tags/1.8.8.tar.gz(本文实测即因直连慢改用代理成功)。

解压:

tar xzf 1.8.8.tar.gz
cd iRedMail-1.8.8/

3.3 dnf 仓库与依赖预检

⚠️ 排障实录(真实踩坑一:仓库不全导致 EPEL 安装失败):精简系统镜像裁掉了 extras/crb 仓库节,安装到 EPEL 步骤会因 epel-release 包不可见而失败(本文实测三次失败后才定位)。先检查仓库分节是否齐全:

$ grep -E '^\[' /etc/yum.repos.d/rocky.repo
[baseos]
[appstream]

若只看到 baseos/appstream 两节(正常应有 baseos/appstream/crb/extras 四节),补全 /etc/yum.repos.d/rocky.repo(本文实测用阿里云镜像源,生产按网络环境选择):

[baseos]
name=Rocky Linux $releasever - BaseOS
baseurl=https://mirrors.aliyun.com/rockylinux/$releasever/BaseOS/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-Rocky-9

[appstream]
name=Rocky Linux $releasever - AppStream
baseurl=https://mirrors.aliyun.com/rockylinux/$releasever/AppStream/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-Rocky-9

[crb]
name=Rocky Linux $releasever - CRB
baseurl=https://mirrors.aliyun.com/rockylinux/$releasever/CRB/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-Rocky-9

[extras]
name=Rocky Linux $releasever - Extras
baseurl=https://mirrors.aliyun.com/rockylinux/$releasever/extras/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-Rocky-9

刷新缓存并确认 epel-release 可见:

$ dnf makecache -q
$ dnf list epel-release
Available Packages
epel-release.noarch    9-7.el9    extras

⚠️ 排障实录(真实踩坑二:curl-minimal 与 curl 冲突):精简镜像自带 curl-minimal,安装到 curl 包时 dnf 报文件冲突中止。提前替换:

$ dnf install -y curl --allowerasing -q
$ rpm -qa | grep -E '^curl(-minimal)?'
curl-7.76.1-31.el9.x86_64

再清理系统残留的 cron 目录问题(实测部分镜像缺 /var/spool/cron,后续 crontab 写入会失败,提前建好):

mkdir -p /var/spool/cron && chmod 700 /var/spool/cron

四、运行安装向导(逐屏实录)

4.1 启动安装

cd /root/iRedMail-1.8.8
bash iRedMail.sh

⚠️ 排障实录(真实踩坑三:安装状态残留导致跳过关键步骤):向导中断重跑时,若 runtime/install.status 中已记录某些阶段完成(如 status_get_all / status_create_repo_rhel),重跑会静默跳过这些阶段。实测现象:修复仓库后重跑,EPEL 一步被跳过仍报错。解决:清掉状态文件中的完成标记再重跑:

$ cat /root/iRedMail-1.8.8/runtime/install.status
status_get_all: done
status_create_repo_rhel: done
...
$ sed -i '/status_get_all\|status_create_repo_rhel/d' /root/iRedMail-1.8.8/runtime/install.status
$ cat /root/iRedMail-1.8.8/runtime/install.status
status_check_new_iredmail: done

(保留无法安全重跑的检测项,删除与失败步骤相关的标记。)重跑时向导检测到已有 config 会询问是否复用,答 y:

[ INFO ] Checking configuration file: /root/iRedMail-1.8.8/config ... Found.
< Question > Use existing config file directly? Yes / No
y

首次运行则进入逐屏配置,与 3.2 起的实录一致。

4.2 逐屏配置实录

欢迎与仓库添加:向导首屏提示干净系统要求,选 Yes 继续后脚本执行 dnf 依赖安装(实测下载 277 个包):

[ INFO ] Install necessary packages: dialog gettext ncurses-term
[ INFO ] Installing packages: nginx postfix postfix-pcre mariadb-server mariadb-devel dovecot dovecot-mysql dovecot-pigeonhole ... amavisd-new spamassassin clamav-server clamav-server-systemd ... fail2ban
Installed:
  postfix-3.5.25-3.el9_8.x86_64  dovecot-2.3.16-18.el9_8.8.x86_64  mariadb-server-10.5.29-3.el9_7.x86_64  nginx-1:1.20.1-28.el9_8.6.rocky.0.1.x86_64  ...

邮箱存储路径:保留默认 /var/vmail,回车:

Storage base directory:
[/var/vmail]

Web 服务器:唯一选项 Nginx,回车确认:

* Web server
[*] Nginx

后端数据库:方向键选 MariaDB 并空格勾选,回车(后端选型对比详见《iRedMail 1.7.4 Ubuntu 22.04 安装指南》4.4 节技术拓展:MariaDB 为默认推荐,OpenLDAP 适合目录生态集成,PostgreSQL 适合已有 PG 运维体系,三种后端存储实体一致):

* Backend used to store mail accounts:
[ ] OpenLDAP
[*] MariaDB
[ ] PostgreSQL

MySQL root 密码、首个邮件域名、域管理员 postmaster 密码(本文演示统一 q1w2e3r4 / example.com):

Password for the MySQL root user:
********
First mail domain name:
example.com
Password for the administrator of your mail domain:
********

可选组件:保持默认全选,回车:

* Optional components:
[*] SOGo groupware (webmail, calendar, address book, active sync)
[*] iRedAdmin (official free & open source edition)
[*] Roundcube webmail
[*] netdata (system monitor)
[*] mlmmj (mailing list manager)
[*] mlmmjadmin (API server to manage mlmmj)
[*] Fail2ban (block brute force login attacks)
[*] iRedAPD (postfix policy server)

配置评审与开始:评审屏列出存储路径 / 域名 / 账号等摘要,选 Yes 后脚本完成全部安装与配置(含 freshclam 更新病毒库,实测下载 daily.cvd 版本 28155):

[ INFO ] Copy MySQL sample file: /etc/my.cnf.
[ INFO ] Updating ClamAV database (freshclam), please wait ...
ClamAV update process started at Sat Oct 17 03:06:54 2026
daily database available for download (remote version: 28155)
Testing database: '/var/lib/clamav/tmp.31beeb907b/clamav-1cc7cc12d3c7b24d70d261983fd3849c.tmp-daily.cvd' ...
Database test passed.
daily.cvd updated (version: 28155, sigs: 355765, f-level: 90, builder: svc.clamav-publisher)

结束时打印 Web 入口摘要并提示重启(实测屏):

********************* WARNING **************************************
*
* Please reboot your system to enable all mail services.
*
********************************************************************
[root@mail iRedMail-1.8.8]#

重启:

reboot

五、安装后验证

5.1 服务状态

$ systemctl is-active postfix
active
$ systemctl is-active dovecot
active
$ systemctl is-active nginx
active
$ systemctl is-active mariadb
active
$ systemctl is-active amavisd
active
$ systemctl is-active clamd@amavisd
active
$ systemctl is-active fail2ban
active
$ systemctl is-active iredapd
active
$ systemctl is-active php-fpm
active
$ systemctl is-active netdata
active

与 Ubuntu 版的单元名差异(同为 iRedMail,包来源不同导致):反垃圾是 amavisd(Ubuntu 为 amavis),杀毒是 clamd@amavisd(Ubuntu 为 clamav-daemon),PHP-FPM 是模块化的 php-fpm(Ubuntu 为 php8.1-fpm)。另注意 spamassassin 单元在本环境为 inactive 属正常——Amavisd 通过程序库内嵌 SpamAssassin,无需独立 spamd 服务:

$ systemctl is-active spamassassin
inactive
$ systemctl --failed --no-legend
● getty@tty1.service loaded failed failed Getty on tty1

⚠️ getty@tty1 失败是无头服务器(无物理 tty)的固有现象,与邮件功能无关,可忽略或 systemctl disable getty@tty1。

5.2 监听端口矩阵

$ ss -lntp | grep -E ':25 |:587 |:143 |:993 |:443 |:19999 '
LISTEN 0      100    0.0.0.0:25     ... users:(("master",pid=563,fd=13))
LISTEN 0      100    0.0.0.0:587    ... users:(("master",pid=563,fd=101))
LISTEN 0      500    0.0.0.0:143    ... users:(("dovecot",pid=89,fd=45))
LISTEN 0      500    0.0.0.0:993    ... users:(("dovecot",pid=89,fd=47))
LISTEN 0      511    0.0.0.0:443    ... users:(("nginx",pid=141,fd=6))
LISTEN 0      4096   127.0.0.1:19999 ... users:(("netdata",pid=79,fd=5))

5.3 Web 入口与登录验证

$ curl -sk -o /dev/null -w 'webmail /mail/ -> %{http_code}\n' https://mail.example.com/mail/
webmail /mail/ -> 200
$ curl -sk -o /dev/null -w 'iredadmin -> %{http_code}\n' https://mail.example.com/iredadmin/
iredadmin -> 200
$ curl -s -o /dev/null -w 'netdata -> %{http_code}\n' http://127.0.0.1:19999/
netdata -> 200

iRedAdmin 登录实测(curl 会话):

$ cj=/tmp/ira.cookies
$ curl -sk -c $cj -d "username=postmaster@example.com&password=q1w2e3r4" https://mail.example.com/iredadmin/login -o /dev/null -w '%{http_code} loc=%{redirect_url}\n'
303 loc=https://mail.example.com/iredadmin/dashboard?checknew
$ curl -sk -b $cj https://mail.example.com/iredadmin/dashboard -o /tmp/d.html -w '%{http_code}\n'
200
$ grep -oE 'Logged in as[^<]*' /tmp/d.html | head -1
Logged in as postmaster@example.com

Roundcube 登录实测:

$ rj=/tmp/rc.cookies
$ curl -sk -c $rj https://mail.example.com/mail/ -o /tmp/rc1.html
$ tok=$(grep -oE '_token" value="[^"]+' /tmp/rc1.html | sed 's/.*value="//' | head -1)
$ curl -sk -b $rj -c $rj --data-urlencode "_token=$tok" --data-urlencode "_user=postmaster@example.com" --data-urlencode "_pass=q1w2e3r4" -d "_action=login&_task=login" https://mail.example.com/mail/ -o /dev/null -w '%{http_code} loc=%{redirect_url}\n'
302 loc=https://mail.example.com/mail/?_task=mail&_token=V1wxrvtk6jGGn2e3eQvuxzVVZ5KSDGjR
$ curl -sk -b $rj "https://mail.example.com/mail/?_task=mail" -o /tmp/rc2.html -w '%{http_code}\n'
200
$ grep -oE '<title>[^<]+' /tmp/rc2.html
<title>Roundcube Webmail :: Inbox

5.4 SMTP 与 IMAP 连通验证

域内 SMTP 投递(Python smtplib 三行实测):

$ python3 - <<'EOF'
import smtplib
from email.mime.text import MIMEText
msg = MIMEText('rocky local delivery test', 'plain', 'utf-8')
msg['Subject'] = 'Rocky local test'
msg['From'] = 'postmaster@example.com'
msg['To'] = 'postmaster@example.com'
s = smtplib.SMTP('127.0.0.1', 25, timeout=30)
s.sendmail(msg['From'], [msg['To']], msg.as_string()); s.quit()
print('SMTP 25 OK')
EOF
SMTP 25 OK

IMAP STARTTLS 收取:

$ python3 - <<'EOF'
import imaplib
m = imaplib.IMAP4('127.0.0.1', 143); m.starttls()
m.login('postmaster@example.com','q1w2e3r4')
typ, data = m.select('INBOX'); print('IMAP OK, INBOX:', data[0].decode())
m.logout()
EOF
IMAP OK, INBOX: 3

INBOX 中 3 封邮件 = 系统欢迎信 2 封 + 本机 SMTP 测试 1 封,与预期一致。

六、卸载 iRedMail

自带卸载脚本(执行前备份 /var/vmail 与数据库):

bash /root/iRedMail-1.8.8/tools/uninstall_iredmail.sh

脚本逐项询问删除邮件存储 / 数据库 / 配置文件,按需答 y。完成后验证:

$ systemctl is-active postfix
inactive

七、常见问题与排障沉淀

7.1 EPEL 安装失败(仓库不全)

症状:安装日志报 epel-release 不可用/仓库 404。原因:精简镜像裁掉 extras/crb 节。解决:按 3.3 节补全 rocky.repo 四节并 dnf makecache,验证 dnf list epel-release 可见。

7.2 curl 包冲突

症状:dnf 安装报 curl-minimal 与 curl 文件冲突。解决:dnf install -y curl --allowerasing 提前替换(见 3.3 节)。

7.3 重跑安装跳过已修复步骤

症状:修好仓库后重跑仍跳过 EPEL。原因:runtime/install.status 残留完成标记。解决:删除对应 status_* 行再重跑(见 4.1 节实录)。

7.4 病毒库更新慢

freshclam 直连 database.clamav.net 慢时耐心等待(实测 daily.cvd 35.5 万签名下载校验约 2-4 分钟);也可配置镜像源(/etc/freshclam.conf 的 DatabaseMirror,国内可选 db.local.clamav.net 相关镜像)。

7.5 Rocky 8 上安装 1.8.x 直接失败

官方已移除支持(ChangeLog 见 2.1 节),Rocky 8 请用 1.7.x 或升级到 Rocky 9。

八、参考链接