Postfix-2.11+Dovecot-2.0.9+MySQL+Nginx+Cyrus-sasl+Extmail-1.2实现基于虚拟用户的邮件系统架构。
系统:
CentOS 7.1
IP:192.168.2.220
域名:mail.test.com
----------------------------------------------------------------------------------------
——安装前的准备工作
1)关闭Selinux
12 [root@node1 ~]# vi /etc/selinux/config
SELINUX=disabled
2)安装程序依赖包
[root@node1 ~]# yum install db4-devel ntpdate cyrus-sasl-md5 perl-GD perl-DBD-MySQL perl-GD perl-CPAN perl-CGI perl-CGI-Session cyrus-sasl-lib cyrus-sasl-plain cyrus-sasl cyrus-sasl-devel libtool-ltdl-devel telnet mail -y
3) 由于CentOS7默认安装的是MariaDB,所以要添加MySQL的yum源,有些编译需要的devel包只有epel有,所以我们把epel源也一并添加
yum install -y wget
wget
rpm -ivh mysql-community-release-el7-5.noarch.rpm
wget Fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -ivh epel-release-latest-7.noarch.rpm
4)安装Unix-Syslog补丁
[root@node1 soft]# wget
[root@node1 soft]# tar fzvx Unix-Syslog-1.1.tar.gz
[root@node1 soft]# cd Unix-Syslog-1.1
[root@node1 Unix-Syslog-1.1]# perl Makefile.PL
[root@node1 Unix-Syslog-1.1]# make && make install
注意:不安装此补丁的话使用extmail会报如下错误:
Unix::Syslog not found, please install it first! (in cleanup) Undefined subroutine &Ext::Logger::do_closelog called at /var/www/extsuite/extmail/libs/Ext/Logger.pm line 86.
----------------------------------------------------------------------------------------
——安装postfix
1)卸载系统自带的postfix软件和用户组
[root@node1 ~]# yum remove postfix -y
[root@node1 ~]# userdel postfix
[root@node1 ~]# groupdel postdrop
2)添加postfix用户和组
[root@node1 ~]# groupadd -g 2525 postfix
[root@node1 ~]# useradd -g postfix -u 2525 -s /sbin/nologin -M postfix
[root@node1 ~]# groupadd -g 2526 postdrop
[root@node1 ~]# useradd -g postdrop -u 2526 -s /sbin/nologin -M postdrop
3)下载postfix
[root@node1 ~]# mkdir /tmp/soft
[root@node1 ~]# cd /tmp/soft
[root@node1 soft]# wget
[root@node1 soft]# tar xfv postfix-2.11.0.tar.gz
[root@node1 soft]# cd postfix-2.11.0
[root@node1 postfix-2.11.0]# make makefiles \
'CCARGS=-DHAS_MYSQL -I/usr/include/mysql -DUSE_SASL_AUTH \
-DUSE_CYRUS_SASL -I/usr/include/sasl -DUSE_TLS ' \
'AUXLIBS=-L/usr/lib64/mysql -lmysqlclient -lz -lrt -lm -L/usr/lib64/sasl2 -lsasl2 -lssl -lcrypto'
[root@node1 postfix-2.11.0]# make && make install
4)配置相应权限
[root@node1 postfix-2.11.0]# chown -R postfix:postdrop /var/spool/postfix
[root@node1 postfix-2.11.0]# chown -R postfix:postdrop /var/lib/postfix/
[root@node1 postfix-2.11.0]# chown root /var/spool/postfix
[root@node1 postfix-2.11.0]# chown -R root /var/spool/postfix/pid
5)配置postfix
[root@node1 postfix-2.12-20140406]# vi /etc/postfix/main.cf
#设置主机名
myhostname = mail.test.com
#指定域名
mydomain = test.com
#指明发件人所在的域名
myorigin = $mydomain
#指定postfix系统监听的网络接口
inet_interfaces = all
#指定postfix接收邮件时收件人的域名 [使用虚拟域需要禁用]
mydestination = $myhostname, localhost.$mydomain, localhost,$mydomain
#指定信任网段类型
mynetworks_style = host
#指定信任的客户端
mynetworks = 192.168.0.0/16, 127.0.0.0/8
#指定允许中转邮件的域名
relay_domains = $mydestination
#设置邮件的别名
alias_maps = hash:/etc/aliases
6)设置开启启动
[root@node1 postfix-2.12-20140406]# chkconfig --add postfix
[root@node1 postfix-2.12-20140406]# chkconfig postfix on
[root@node1 postfix-2.12-20140406]# service postfix restart
[root@node1 postfix-2.12-20140406]# netstat -antup |grep 25
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 1917/master
----安装Dovecot
1)安装Dovecot
1 [root@node1 ~]# yum install -y dovecot dovecot-devel dovecot-mysql
2)配置Dovecot
1234567891011121314151617181920212223242526272829 [root@node1 soft]# cd /etc/dovecot/
[root@node1 dovecot]# vi dovecot.conf
protocols = imap pop3
!include conf.d/*.conf
listen = *
base_dir = /var/run/dovecot/
[root@node1 dovecot]# cd conf.d/
[root@node1 conf.d]# vi 10-auth.conf
disable_plaintext_auth = no
[root@node1 conf.d]# vi 10-mail.conf
mail_location = maildir:~/Maildir
mail_location = maildir:/var/mailbox/%d/%n/Maildir
mail_privileged_group = mail
[root@node1 conf.d]# vi 10-ssl.conf
ssl = no
[root@node1 conf.d]# vi 10-logging.conf
log_path = /var/log/dovecot.log
info_log_path = /var/log/dovecot.info
log_timestamp = "%Y-%m-%d %H:%M:%S "
[root@node1 conf.d]# cp auth-sql.conf.ext auth-sql.conf
[root@node1 conf.d]# vi auth-sql.conf
passdb {
driver = sql
args = /etc/dovecot/dovecot-sql.conf
}
userdb {
driver = sql
args = /etc/dovecot/dovecot-sql.conf
}