https://onitroad.com 更多教程

在 CentOS 7 上安装 EPEL yum 软件库

iRedMail 软件需要来自 EPEL (Extra Packages for Enterprise Linux) yum 存储库的一些包。
因此,我们在继续之前安装 EPEL。

[root@iredmail-01 ~]# yum install -y epel-release

验证 iRedMail 服务器的 DNS 设置

在配置私有邮件服务器之前,必须有一个权威 DNS 服务器。

DNS 服务器必须回答 MX(邮件交换)查询,因此应将电子邮件重定向到我们的 iRedMail 邮件服务器。

如果我们有 DNS 服务器,则其中添加 MX 和 iredmail-01.onitroad.com 的 A 记录。

要正确验证 iRedMail 服务器的 DNS 设置,我们可以使用 dig 命令。

[root@iredmail-01 ~]# dig -t MX onitroad.com
; <<>> DiG 9.9.4-RedHat-9.9.4-74.el7_6.2 <<>> -t MX onitroad.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 40248
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 3
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;onitroad.com.                   IN      MX
;; ANSWER SECTION:
onitroad.com.            3600    IN      MX      0 iredmail-01.onitroad.com.
;; AUTHORITY SECTION:
onitroad.com.            3600    IN      NS      dns-01.onitroad.com.
;; ADDITIONAL SECTION:
iredmail-01.onitroad.com. 3600   IN      A       192.168.1.200
dns-01.onitroad.com.     3600    IN      A       192.168.1.4
;; Query time: 1 msec
;; SERVER: 192.168.1.4#53(192.168.1.4)
;; WHEN: Fri Sep 06 19:23:22 PKT 2019
;; MSG SIZE  rcvd: 121

从上面的输出中,我们可以看到,我们的 iRedMail 服务器的 MX 和 A 记录已正确添加到 DNS 服务器中。

在 CentOS 7 上安装 iRedMail 服务器

iRedMail 是一个开源的、功能齐全的邮件服务器解决方案,可以为系统管理员节省大量复杂配置的时间。

iRedMail 支持所有主要的 Linux 发行版。
iRedMail 使用其他开源软件,如 roundcube、SOGo 群件、Netdata、Nginx 和 MariaDB,为其邮件服务器添加功能。

iRedMail 有两个版本,iRedMail(免费)和 iRedMail Easy(商业)。
在本文中,我们将在 CentOS 7 上安装 iRedMail(免费)服务器。

在 CentOS 7 上验证 iRedMail 安装

重启后,在客户端浏览器中浏览 URL https://iredmail-01.onitroad.com/mail/ 访问 RoundCube WebMail 。

使用上述命令中提供的凭据登录。

  • 用户名:postmaster@onitroad.com
  • 密码 : JackLi@1234

我们现在在 postmaster@onitroad.com 用户的收件箱中。

现在浏览 URL https://iredmail-01.onitroad.com/sogo/ 以连接到 SOGo 网络客户端。

使用我们在上面使用的相同凭据登录。

我们到达了 SOGo 网络客户端的收件箱。

现在浏览 URL https://iredmail-01.onitroad.com/netdata/ 以连接到 Netdata 监视器。

再次使用相同的凭据登录。

我们现在在 Netdata 监视器的仪表板上。

现在浏览 URL https://iredmail-01.onitroad.com/iredadmin/ 以连接到 iRedAdmin 管理控制台。

使用相同的凭据再次登录。

我们现在在 iRedAdmin 管理控制台的仪表板上。

所有四个组件都工作正常。
我们已经在 CentOS 7 上成功安装了 iRedMail 服务器。

停止服务器上现有的 MTA 服务

默认情况下,CentOS 7 将 Postfix 安装为 MTA(邮件传输代理)。
在继续安装 iRedMail 服务器之前,我们需要禁用它。

停止并禁用 postfix.service 。

[root@iredmail-01 ~]# systemctl stop postfix.service
[root@iredmail-01 ~]# systemctl disable postfix.service
Removed symlink /etc/systemd/system/multi-user.target.wants/postfix.service.
[root@iredmail-01 ~]# systemctl mask postfix.service
Created symlink from /etc/systemd/system/postfix.service to /dev/null.

在 CentOS 7 上下载并安装 iRedMail 服务器

iRedMail 0.9.9 (Stable) 版本可在 iRedMail 官网下载。

使用 wget 命令下载 iRedMail 软件。

[root@iredmail-01 ~]# cd /tmp
[root@iredmail-01 tmp]# wget https://bitbucket.org/zhb/iredmail/downloads/iRedMail-0.9.9.tar.bz2

使用 tar 命令解压下载的 zip 文件。

[root@iredmail-01 tmp]# tar xvf iRedMail-0.9.9.tar.bz2

如下启动 iRedMail 服务器安装。

[root@iredmail-01 tmp]# cd iRedMail-0.9.9/
[root@iredmail-01 tmp]# bash iRedMail.sh

iRedMail 安装程序会自动从 CentOS 7 yum 存储库安装所需的软件包,并从其网站下载 iRedMail 的组件。

我们现在位于 iRedMail 安装程序的欢迎屏幕。
选择是,然后按 <ENTER>。

如果我们计划使用不同的磁盘/分区来存储邮箱,请提供存储用户邮箱的路径。
否则,我们可以使用 iRedMail 安装程序提供的默认路径。

选择下一步并按 <ENTER>。

iRedMail 安装程序现在要求选择首选 Web 服务器。
使用 <SPACE> 键选择 Nginx。

选择下一步并按 <ENTER>。

根据喜好为电子邮件帐户选择后端存储。
由于管理是由一个通用的 iRedAdmin 管理控制台执行的,因此我们可能不会感觉到任何功能上的大差异。

选择下一步并按 <ENTER>。

因为,我们选择 OpenLDAP 作为我们的后端存储,因此,它要求 LDAP 后缀。
根据环境提供 LDAP 后缀。

按 <ENTER>。

虽然我们没有选择 MariaDB 作为后端存储,但是 iRedMail 服务器内部仍然使用它。
因此,为 MySQL root 用户提供一个强密码。
按 <ENTER> 继续。

提供邮件域并按 <ENTER>。

为邮件域管理员提供强密码。

按 <ENTER> 继续。

根据要求安装任何可选组件。

按 <ENTER> 继续。

*
* WARNING ***
*
*                                                                       *
* Below file contains sensitive infomation (username/password), please  *
* do remember to *MOVE* it to a safe place after installation.          *
*                                                                       *
*   * /tmp/iRedMail-0.9.9/config
*                                                                       *
*
** Review your settings *
*
* Storage base directory:               /var/vmail
* Mailboxes:
* Daily backup of SQL/LDAP databases:
* Store mail accounts in:               OpenLDAP
* Web server:                           Nginx
* First mail domain name:               onitroad.com
* Mail domain admin:                    postmaster@onitroad.com
* Additional components:                Roundcubemail SOGo netdata iRedAdmin Fail2ban
< Question > Continue? [y|N]

iRedMail 安装程序正在确认我们在之前屏幕中提供的设置。

如果我们对设置满意,请输入 y。

iRedMail 安装程序将自动完成安装包和依赖项的所有工作。

python-requests.noarch 0:2.6.0-1.el7_1
  python-setuptools.noarch 0:0.9.8-7.el7
  python-sqlalchemy.x86_64 0:0.9.8-2.el7
...
  zip.x86_64 0:3.0-11.el7
Updated:
  curl.x86_64 0:7.29.0-51.el7_6.3        iproute.x86_64 0:4.11.0-14.el7_6.2
  libuuid.x86_64 0:2.23.2-59.el7_6.1     openldap.x86_64 0:2.4.44-21.el7_6
Dependency Updated:
...
  systemd-sysv.x86_64 0:219-62.el7_6.9  util-linux.x86_64 0:2.23.2-59.el7_6.1
Complete!

* Start iRedMail Configurations

[ INFO ] Generate self-signed SSL cert (2048 bits, expire in 10 years).
...
Downloading daily.cvd [100%]
daily.cvd updated (version: 25564, sigs: 1751582, f-level: 63, builder: raynman)
Downloading bytecode.cvd [100%]
bytecode.cvd updated (version: 330, sigs: 94, f-level: 63, builder: neo)
Database updated (6317925 signatures) from database.clamav.net (IP: 104.16.219.84)

* URLs of installed web applications:
*
* - Roundcube webmail: https://iredmail-01.onitroad.com/mail/
* - SOGo groupware: https://iredmail-01.onitroad.com/SOGo/
* - netdata (monitor): https://iredmail-01.onitroad.com/netdata/
*
* - Web admin panel (iRedAdmin): https://iredmail-01.onitroad.com/iredadmin/
*
* You can login to above links with below credential:
*
* - Username: postmaster@onitroad.com
* - Password: JackLi@1234
*
*

* Congratulations, mail server setup completed successfully. Please
* read below file for more information:
*
*   - /tmp/iRedMail-0.9.9/iRedMail.tips
*
* And it's sent to your mail account postmaster@onitroad.com.
*
* WARNING **
*
* Please reboot your system to enable all mail services.
*

删除 iRedMail 安装程序使用的配置文件,因为它包含一些关键信息,如管理员密码。

[root@iredmail-01 iRedMail-0.9.9]# rm -f config

现在使用以下命令重新启动我们的 CentOS 7 服务器。

[root@iredmail-01 iRedMail-0.9.9]# systemctl reboot

在 CentOS 7 防火墙中允许 HTTPS 服务。

[root@iredmail-01 iRedMail-0.9.9]# firewall-cmd --permanent --add-service=https
success
[root@iredmail-01 iRedMail-0.9.9]# firewall-cmd --reload
success

在 CentOS 7 服务器上禁用 SELinux

iRedMail 服务器与 SELinux 不兼容,建议在其文档中在继续安装之前禁用 SELinux。

[root@iredmail-01 ~]# setenforce 0
[root@iredmail-01 ~]# sed -i 's/^SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config && cat /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted
日期:2020-09-17 00:16:39 来源:oir作者:oir