--時間:2020年10月20日html
--做者:飛翔的小胖豬python
iRedMail 是一個基於 Linux/BSD 系統的零成本、功能完備、成熟的郵件服務器解決方案。iRedMail 是一個開源、免費的項目。以 GPL(v2)協議發佈。mysql
在我實際生產環境中須要搭建一套郵件服務器,百度了一下據說iredmail不錯,一步一步來唄。大體流程以下:linux
1.先在本身環境下作測試,若是能成功再搞到生產環境中。web
2.打開其官方網站根據本身實際的設備環境(操做系統)找到合適的安裝步驟。(儘可能要英文手冊)sql
3.根據你所看到的步驟提示一步一步的走,而後就安裝好了。這有一個前提你的安裝環境必須與互聯網相通。docker
4.經過觀察iredmail的安裝實時提示信息發現他會去互聯網中下載不少東西,可個人內網環境不能連通互聯網呀。看了一下官網上又沒有提供離線安裝包下載,好吧看來要消耗一波腦細胞了。數據庫
5.經過一成天的各類嘗試終於然我找到一套可行的離線安裝方式。vim
系統及軟件:centos
數據準備:
安裝包下載:
該安裝包是由本人從iredmail官網上下載的文件而後製做的離線安裝軟件包。現放在百度網盤中,該篇文檔也是使用該包來完成安裝的。
連接:https://pan.baidu.com/s/1yaOS8CciAjFjeN5IHIW3-w
提取碼:wowb
ps:可能只適用與centos 7.6+iredmail-1.3.1的環境,其餘操做系統及軟件版本也沒測過。
包文件說明:
軟件包主要分爲4塊。
.官網軟件包:iRedMail-1.3.1.tar.gz + misc
.安裝所需的epel源中的rpm文件:yum_down_soft.tar.gz
.cvd病毒庫:cvd
.python2及3的各類必要模塊:python
安裝操做系統
操做系統安裝這一步就不介紹了,請自行百度謝謝!!!切記我用的是Centos 7.6的系統,安裝軟件選擇最簡潔的最小化安裝便可。
配置系統
進入到操做系統事後須要關閉selinux及firewalld,同時要設置機器主機名、掛載本地repo鏡像。
(網絡配置這些基礎配置自行百度)
.設置主機名
1.#使用名設置主機名爲咱們事先規劃好的名字
[root@test1 ~]# hostnamectl set-hostname test1.mail.com [root@test1 ~]# hostname
test1.mail.com
2.修改/etc/hosts文件把主機名添加到文本中,須要添加到最前面
[root@test1 ~]# vim /etc/hosts
127.0.0.1 test1.mail.com localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
.關閉selinux
1.命令臨時設置selinux爲只記錄
[root@test1 ~]# setenforce 0 [root@test1 ~]# getenforce Disabled
2.修改/etc/selinux/config文件中的SELINUX=enforcing爲SELINUX=disabled
[root@test1 ~]# vim /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
.關閉firewalld
#中止firewalld服務同時設置其開機不自動啓動,設置不能被其餘應用調用。
[root@test1 ~]# systemctl stop firewalld [root@test1 ~]# systemctl disable firewalld Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service. Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service. [root@test1 ~]# systemctl mask firewalld
.掛載本地光盤鏡像
#掛載本地光盤到/mnt目錄中
[root@test1 ~]# mount /dev/sr0 /mnt
mount: /dev/sr0 is write-protected, mounting read-only
#刪除/etc/yum.repos.d/下系統自帶的repo文件
[root@test1 ~]# cd /etc/yum.repos.d/
[root@test1 yum.repos.d]# rm -rf CentOS-*
#新建編輯一個名爲local_yum.repo的yum源文件
[root@test1 ~]# vim /etc/yum.repos.d/local_yum.repo
[yum_local]
name=yum_local
enabled=1
gpgcheck=0
baseurl=file:///mnt/
[root@test1 yum.repos.d]# yum clean all
[root@test1 yum.repos.d]# yum makecache
[root@test1 yum.repos.d]# yum repolist
解壓文件
經過本人分享的百度連接下載獲得安裝軟件包,而後解壓到根目錄下。
1.解壓總的安裝包
[root@test1 ~]# ll /iredmail.tar.gz -rw-r--r-- 1 root root 487738299 Oct 20 11:47 /iredmail.tar.gz [root@test1 ~]# [root@test1 ~]# [root@test1 ~]# tar -zxvf /iredmail.tar.gz -C / #解壓壓縮包到根目錄下
[root@test1 ~]# cd /soft
[root@test1 soft]# ll
total 194128
drwxr-xr-x 2 root root 59 Oct 20 11:42 cvd
-rw-r--r-- 1 root root 232203 Oct 16 08:47 iRedMail-1.3.1.tar.gz
drwxr-xr-x 2 root root 226 Oct 20 11:44 misc
drwxr-xr-x 4 root root 56 Oct 20 11:43 python
-rw-r--r-- 1 root root 198550344 Oct 19 16:50 yum_down_soft.tar.gz
2.解壓rpm軟件包。
[root@test1 soft]# tar -zxvf yum_down_soft.tar.gz
3.解壓iredmail文件
[root@test1 soft]# tar -zxvf iRedMail-1.3.1.tar.gz
[root@test1 soft]# ll
total 194152
drwxr-xr-x 2 root root 59 Oct 20 11:42 cvd
drwxr-xr-x 10 root root 193 Sep 22 05:34 iRedMail-1.3.1
-rw-r--r-- 1 root root 232203 Oct 16 08:47 iRedMail-1.3.1.tar.gz
drwxr-xr-x 2 root root 226 Oct 20 11:44 misc
drwxr-xr-x 4 root root 56 Oct 20 11:43 python
drwxr-xr-x 3 root root 20480 Oct 18 23:32 yum_down_soft
-rw-r--r-- 1 root root 198550344 Oct 19 16:50 yum_down_soft.tar.gz
修改部分腳本
在iredmail安裝腳本中會自動生成一個sogo的repo文件每次。在外網環境下他會經過自動生成的repo文件去找到須要的包並進行下載。在內網中則會由於沒法鏈接外網而安裝報錯。
咱們須要修改其自動生成repo的語句改成咱們本地的路徑。
在/soft/iRedMail-1.3.1/functions/packages.sh文件中註釋掉baseurl=${SOGO_PKG_MIRROR}/SOGo/nightly/${SOGO_VERSION}/rhel/${DISTRO_VERSION}/\$basearch行(大概在文件的408行左右),而後添加一行新數據指定生成的repo路徑爲本地路徑。
[root@test1 soft]# vim /soft/iRedMail-1.3.1/functions/packages.sh
cat > ${YUM_REPOS_DIR}/sogo.repo <<EOF
[SOGo]
name=Inverse SOGo Repository
enabled=1
gpgcheck=0
# SOGo v3 stable release.
# WARNING: A proper support contract from Inverse is required:
# https://sogo.nu/support/index.html#support-plans
#baseurl=${SOGO_PKG_MIRROR}/SOGo/release/${SOGO_VERSION}/rhel/${DISTRO_VERSION}/\$basearch
# SOGo v3 nightly builds
#baseurl=${SOGO_PKG_MIRROR}/SOGo/nightly/${SOGO_VERSION}/rhel/${DISTRO_VERSION}/\$basearch #被註釋掉的行
baseurl=file:///soft/yum_down_soft #新添加的行,根據前文所知個人rpm包放在/soft/yum_down_soft目錄下
EOF
拷貝軟件到指定位置
拷貝安裝過程當中的軟件到指定的位置,若是沒有相關文件夾請自行建立。
拷貝/soft/misc目錄到/soft/iRedMail-1.3.1/pkgs/
[root@test1 soft]# cp -rp /soft/misc /soft/iRedMail-1.3.1/pkgs/
[root@test1 soft]# ll /soft/iRedMail-1.3.1/pkgs/misc/ #確認複製成功
total 42972
-rw-r--r-- 1 root root 395656 Oct 20 11:44 iRedAdmin-1.0.tar.bz2
-rw-r--r-- 1 root root 102870 Oct 20 11:44 iRedAPD-4.3.tar.gz
-rw-r--r-- 1 root root 1849829 Oct 20 11:44 libsodium-1.0.18-stable.tar.gz
-rw-r--r-- 1 root root 40622 Oct 20 11:44 mlmmjadmin-3.0.tar.gz
-rwxr-xr-x 1 root root 34464172 Oct 20 11:44 netdata-v1.23.1.gz.run
-rw-r--r-- 1 root root 7031947 Oct 20 11:44 roundcubemail-1.4.7-complete.tar.gz
-rw-r--r-- 1 root root 105522 Oct 20 11:44 webpy-0.51.tar.gz
一切準備就緒那就能夠安裝了,安裝的步驟和官網的如出一轍但有幾部又有不一樣。建議打開兩個終端,一個用來安裝iredmail一個cd到/etc/yum.repos.d目錄下準備修改repo文件。
[root@test1 ~]# cd /soft/iRedMail-1.3.1/
[root@test1 iRedMail-1.3.1]# bash iRedMail.sh
而後就是大帕拉的各類提示,此時應該會報錯以下:
5. Configure the failing repository to be skipped, if it is unavailable.
Note that yum will try to contact the repo. when it runs most commands,
so will have to try and fail each time (and thus. yum will be be much
slower). If it is a very temporary problem though, this is often a nice
compromise:
yum-config-manager --save --setopt=iRedMail.skip_if_unavailable=true
failure: repodata/repomd.xml from iRedMail: [Errno 256] No more mirrors to try.
https://dl.iredmail.org/yum/rpms/7/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: dl.iredmail.org; Unknown error"
[ INFO ] Checking configuration file: /soft/iRedMail-1.3.1/config ...[ INFO ] NOT FOUND. Launching installation wizard.
/soft/iRedMail-1.3.1/dialog/config_via_dialog.sh: line 44: dialog: command not found
修改/etc/yum.repos.d/iRedMail.repo爲以下內容後再執行安裝。
[root@test1 ~]# vim /etc/yum.repos.d/iRedMail.repo
[iRedMail]
name=iRedMail
#baseurl=https://dl.iredmail.org/yum/rpms/$releasever/
baseurl=file:///soft/yum_down_soft
enabled=1
gpgcheck=0
#exclude=postfix*
priority=99
module_hotfixes=1
[root@test1 ~]# cd /soft/iRedMail-1.3.1/
[root@test1 iRedMail-1.3.1]# bash iRedMail.sh
直接鼠標點擊<Yes>進入下一步。
定義你的郵件存儲路徑,自定義的,若是存儲比較有空那麼能夠掛一張新盤來做爲郵件存儲。
選擇安裝郵件服務器運行web服務。
郵件中的用戶管理使用mysql數據庫。
設置mysql的密碼,自定義的。
建立一個域名。
設置郵件管理員的密碼。
無論全選,具體選項功能看其後的英文註釋很清楚。
再次確認你的設置,確認無誤後輸入Y敲回車繼續安裝。
輸入了Y後,敲回車,系統會進行軟件包的安裝。
當安裝停在/etc/firewalld/zones/iredmail.xm,with SSHD ports:22. [Y|n] 行時先不要動。新開一個終端進行以下操做。
此處的命令請新開一個終端執行。 [root@test1 ~]# pip install --no-index --find-links /soft/python/2 -r /soft/python/pip2.txt #安裝python2的模塊 [root@test1 ~]# pip3 install --no-index --find-links /soft/python/3 -r /soft/python/pip3.txt #安裝python3的模塊
複製包內的cvd病毒庫文件置/var/lib/clamav/下並修改全部者。 [root@test1 lib]# cp /soft/cvd/* /var/lib/clamav/ [root@test1 lib]# chown clamupdate:clamupdate /var/lib/clamav/* [root@test1 lib]# ll /var/lib/clamav/
以上的內存執行好了再回到以前的終端「Y」。
最後你能夠相似以下的信息,請從********************************************************************* URLs of installed web applications:處開始複製下來,或拍照,否則之後忘了。
而後根據提示重啓服務器完成安裝。
.................................
Reading CVD header (daily.cvd): Giving up on https://database.clamav.net... ******************************************************************** * URLs of installed web applications: * * - Roundcube webmail: https://test1.mail.com/mail/ * - SOGo groupware: https://test1.mail.com/SOGo/ * - netdata (monitor): https://test1.mail.com/netdata/ * * - Web admin panel (iRedAdmin): https://test1.mail.com/iredadmin/ * * You can login to above links with below credential: * * - Username: postmaster@mail.com * - Password: 123456 * * ******************************************************************** * Congratulations, mail server setup completed successfully. Please * read below file for more information: * * - /soft/iRedMail-1.3.1/iRedMail.tips * * And it's sent to your mail account postmaster@mail.com. * ********************* WARNING ************************************** * * Please reboot your system to enable all mail services. * ********************************************************************
* - Roundcube webmail: https://test1.mail.com/mail/ #郵件收發web界面,全部人可登陸
* - SOGo groupware: https://test1.mail.com/SOGo/ #郵件收發web界面,全部人可登陸
* - netdata (monitor): https://test1.mail.com/netdata/ #很酷炫的一個資源監控界面,使用域管理員登陸。
* - Web admin panel (iRedAdmin): https://test1.mail.com/iredadmin/ #郵件管理web界面,使用域管理員登陸。用做管理郵件系統,建立域、用戶什麼的。。。。
請逐一建議檢查以上這4個界面是否可用。有問題能夠私信我。
在內網環境沒法鏈接互聯網時,想要在內網中部署一套須要須要各類外部包和數據的軟件及應用不是一件特別輕鬆的事。
針對這種狀況通常有兩種方法。
.找到軟件的全部依賴包和所需的數據下載打包起來在安裝的過程當中手動把須要的數據庫拷貝到指定的位置。
.搭建套Docker環境,在互聯網的環境中使用容器事先軟件安裝部署,而後打包容器爲image,在內網環境中安裝docker環境,而後load一下以前打包好的鏡像,最後docker run一下就搞定了。
容器真香哈哈。
翻譯過來的中文操做文檔全是坑。