目錄表

CentOS7 安裝 iRedMail Mail Server

環境準備

下載安裝 iRedMail

su - root
yum install wget bzip2
cd /root/
wget https://bitbucket.org/zhb/iredmail/downloads/iRedMail-0.9.9.tar.bz2
tar xjf iRedMail-0.9.9.tar.bz2
cd /root/iRedMail-0.9.9/
bash iRedMail.sh
  • 如果執行安裝時一直出現 /etc/hosts 的設定錯誤, 請先用
    hostname -f

    是否能夠正確出現標準 FQDN 格式 Exp. iredmai.ichiayi.com

  • 如果是安裝在中國機房, 因為 iredmail.org 被 GFW 封鎖, 所以要改用以下語法
    IREDMAIL_EPEL_MIRROR='http://mirrors.aliyun.com/epel'
    IREDMAIL_MIRROR='https://dl.iredmail.org' bash iRedMail.sh
  • 安裝完成後重要資訊會產生在 /root/iRedMail-0.9.8/iRedMail.tips 檔案內

相關設定與驗證測試

修改主機名稱的處理方式

SSL 憑證設定

  • 如果 SSL 憑證與 Mail Server 在不同主機上, 每次憑證更新後可透過 rsync 方式來進行跨主機同步
  • Exp. SSL 憑證存在 192.168.11.234 主機上, 可在 Mail Server 執行以下的同步語法:

白名單與黑名單設定

郵件移轉 (imapsync)

  • 執行後, 會在執行目錄底下產生 LOG_imapsync 目錄, 裡面會有執行過程的紀錄檔案 Exp. 2018_09_07_11_35_30_testalbert.txt
  • 記錄檔內出現 Err 的項目表示同步時出現異常的信件匣, 需要另外處理 Exp.
    Err 1/2: Could not create folder [from Albert/&ZbBbomI2--Data/INDIA/ABC.] from [from Albert/&ZbBbomI2--Data/INDIA/ABC.]: 38252 NO [CANNOT] Character not allowed in mailbox name: '.' (0.001 + 0.000 secs).
    :

更新版本程序

  1. Upgrade iRedAPD → 5.0.2 - https://docs.iredmail.org/upgrade.iredapd.html
    su - root
    mkdir -p 0.9.9
    cd 0.9.9
    wget -O iRedAPD-5.0.2.tar.gz https://github.com/iredmail/iRedAPD/archive/5.0.2.tar.gz
    tar zxf iRedAPD-5.0.2.tar.gz
    cd iRedAPD-5.0.2/tools/
    bash upgrade_iredapd.sh

    查看更新紀錄

    tail -500 /var/log/iredapd/iredapd.log
  2. Upgrade iRedAdmin → 1.3 - https://docs.iredmail.org/migrate.or.upgrade.iredadmin.html
    cd /root/0.9.9
    wget https://dl.iredmail.org/yum/misc/iRedAdmin-1.3.tar.gz
    tar zxvf iRedAdmin-1.3.tar.gz
    cd iRedAdmin-1.3/tools/
    bash upgrade_iredadmin.sh
  3. Upgrade mlmmjadmin → 3.1.2 - https://docs.iredmail.org/upgrade.mlmmjadmin.html
    cd /root/0.9.9
    wget https://github.com/iredmail/mlmmjadmin/archive/3.1.2.tar.gz
    tar zxf 3.1.2.tar.gz
    cd mlmmjadmin-3.1.2/tools/
    bash upgrade_mlmmjadmin.sh
  4. Upgrade Roundcube webmail → 1.4.11 - https://github.com/roundcube/roundcubemail/wiki/Upgrade
    cd /root/0.9.9
    wget https://github.com/roundcube/roundcubemail/releases/download/1.4.11/roundcubemail-1.4.11-complete.tar.gz
    tar xf roundcubemail-*.tar.gz
    cd roundcubemail-*
    bin/installto.sh /var/www/roundcubemail

    如果無法執行 /bin/installto.sh 可能要檢查 /etc/php.ini 內是否關閉 system 的命令使用

  5. Upgrade netdata → 1.12.0 - https://docs.iredmail.org/upgrade.netdata.html
    wget https://github.com/netdata/netdata/releases/download/v1.12.0/netdata-v1.12.0.gz.run
    chmod +x netdata-*.gz.run
    ./netdata-*.gz.run --accept
  6. Fix improper Nginx config files for Roundcube
    vi /etc/nginx/templates/roundcube.tmpl
    :
    location ~ ^/mail/(bin|config|installer|logs|SQL|temp|vendor)($|/.*) { deny all; }
    :
    location ~ ^/mail/(CHANGELOG|composer.json|INSTALL|jsdeps.json|LICENSE|README|UPGRADING)($|.*) { deny all; }
    :
    location ~ ^/mail/plugins/.*/config.inc.php.* { deny all; }
    :
    location ~ ^/mail/plugins/enigma/home($|/.*) { deny all; }
    :
    vi /etc/nginx/templates/roundcube-subdomain.tmpl
    :
    location ~ ^/(bin|config|installer|logs|SQL|temp|vendor)/.* { deny all; }
    :
    location ~ ^/(CHANGELOG|composer.json|INSTALL|jsdeps.json|LICENSE|README|UPGRADING)$ { deny all; }
    :
    location ~ ^/plugins/.*/config.inc.php.* { deny all; }
    :
    location ~ ^/plugins/enigma/home($|/.*) { deny all; }
    :
  7. Improve mlmmj script used for appending footer text
    cd /usr/bin/
    wget -O mlmmj-amime-receive https://raw.githubusercontent.com/iredmail/iRedMail/master/samples/mlmmj/mlmmj-amime-receive
    chown mlmmj:mlmmj mlmmj-amime-receive
    chmod 0550 mlmmj-amime-receive
  8. Fix address mapping issue for mlmmj mailing list
    vi /etc/amavisd/amavisd.conf
    :
    $policy_bank{'MLMMJ'} = {
        ...
        forward_method => 'smtp:[127.0.0.1]:10028',
    };
    :
    vi /etc/postfix/master.cf
    :
    127.0.0.1:10028 inet n  -   n   -   -  smtpd
        -o syslog_name=postfix/10028
        -o content_filter=
        -o mynetworks_style=host
        -o mynetworks=127.0.0.1
        -o local_recipient_maps=
        -o relay_recipient_maps=
        -o strict_rfc821_envelopes=yes
        -o smtp_tls_security_level=none
        -o smtpd_tls_security_level=none
        -o smtpd_restriction_classes=
        -o smtpd_delay_reject=no
        -o smtpd_client_restrictions=permit_mynetworks,reject
        -o smtpd_helo_restrictions=
        -o smtpd_sender_restrictions=
        -o smtpd_recipient_restrictions=permit_mynetworks,reject
        -o smtpd_end_of_data_restrictions=
        -o smtpd_error_sleep_time=0
        -o smtpd_soft_error_limit=1001
        -o smtpd_hard_error_limit=1000
        -o smtpd_client_connection_count_limit=0
        -o smtpd_client_connection_rate_limit=0
        -o receive_override_options=no_header_body_checks,no_unknown_recipient_checks
    
    systemctl restart postfix 
    systemctl restart amavisd 
  9. Fixed: SOGo backup script 1)
    cd /var/vmail/backup/
    wget -O backup_sogo.sh https://raw.githubusercontent.com/iredmail/iRedMail/master/tools/backup_sogo.sh
    chown root backup_sogo.sh
    chmod 0400 backup_sogo.sh
  10. MySQL/MariaDB special
    1. SQL structure changes in vmail database
      cd /root/0.9.9
      wget -O iredmail.mysql https://raw.githubusercontent.com/iredmail/iRedMail/master/update/0.9.9/iredmail.mysql
      mysql vmail < iredmail.mysql
    2. Dovecot: read mailbox format from SQL
      vi /etc/dovecot/dovecot-mysql.conf
      :
      user_query = SELECT \
                  ...
                  LOWER(CONCAT(mailbox.storagebasedirectory, '/', mailbox.storagenode, '/', mailbox.maildir)) AS home, \
                  CONCAT(mailbox.mailboxformat, ':~/', mailbox.mailboxfolder, '/') AS mail, \
                  ...
      :
      systemctl restart dovecot
  11. 更新 /etc/iredmail-release 內容為 0.9.9
    vi /etc/iredmail-release
    0.9.9
    #0.9.8 MARIADB edition.
    :

其他議題

關閉 netdata

關閉 SPF 的方式

出現 postfix/amavis/smtp[6831]: connect to 127.0.0.1[127.0.0.1]:10024: Connection refused 問題

忘記 iRedAdmin 登入的管理者密碼處理方式

備份與還原

參考網址

1)
如果安裝時有更改目錄 Exp. /maildata/backup, 就依照更改的目錄執行