一.实验环境
1.
操作系统RHEL4-U4,内核2.6.9-42.ELsmp
2.
服务器外网IP为124.193.106.77,内网IP为192.168.4.188
3.
域为:begindo.cn
二.Extmail安装
1.下载软件包
我们统一将软件包下载到/root目录里。
cd /root
wget
http://www.extmail.org/source/ExtMail-Solution-Linux-0.2.tar.gz
2.校验
下载的文件必须校验确认过没损坏才能使用。命令如下:
wget http://www.extmail.org/source/md5sum.es_linux-0.2
cat md5sum.es_linux-0.2
md5sum ExtMail-Solution-Linux-0.2.tar.gz
一个可能的结果:
# cat md5sum.es_linux-0.2
168eced41c0cac0ed9f981e791f3783b ExtMail-Solution-Linux-0.2.tar.gz
# md5sum ExtMail-Solution-Linux-0.2.tar.gz
168eced41c0cac0ed9f981e791f3783b ExtMail-Solution-Linux-0.2.tar.gz
由于软件包不断的变更,所以上述结果和您的结果可能不一致,请以下载的md5sum为准
3.解压
目前最新的ExtMail-Solution软件包版本号为0.2,软件包文件名为:ExtMail-Solution-Linux-0.2.tar.gz,下载回来后,在/root目录解开:
tar xfz ExtMail-Solution-Linux-0.2.tar.gz
此外,我们假设本次安装默认域是begindo.cn,主机名为:mail.begindo.cn,ExtMail Solution的文件目录是/root/ExtMail-Solution-Linux-0.2/
重要步骤:
我们进入/root/ExtMail-Solution-Linux-0.2/目录,该目录下包括如下文件/目录:
conf/
docs/
RPMS/
src/
README
其中RPMS目录是本文的重点,里面包含了所需要的全部rpm包,src目录则是存放webmail, anti-spam等相关软件的源码,而README则是说明文件,docs目录则是本文档相关的html及图片。
下文所涉及的操作,绝大部分都是发生在/root/ExtMail-Solution-Linux-0.2目录里,请确保当前目录为:/root/ExtMail-Solution-Linux-0.2
4.
配置Postfix MTA
删除冲突软件,sendmail,需要执行:
rpm -e --nodeps sendmail
rpm –qa | grep sendmail
rpm –e 所有有关sendmail的rpm包
rpm –qa | grep postfix
rpm –e 所有系统自带的postfix的包
5.安装postfix
rpm -ivh --nodeps RPMS/postfix-2.5.1-2ext.i386.rpm
简化postfix配置:
postconf -n > /etc/postfix/main2.cf
mv /etc/postfix/main.cf /etc/postfix/main.cf.old
mv /etc/postfix/main2.cf /etc/postfix/main.cf
再编辑main.cf:
vi /etc/postfix/main.cf
增加如下内容:
# hostname
mynetworks = 127.0.0.1
myhostname = mail.begindo.cn
mydomain = begindo.cn
mydestination = $mynetworks $myhostname
# banner
mail_name = Postfix - by begindo.cn
smtpd_banner = $myhostname ESMTP $mail_name
# response immediately
smtpd_error_sleep_time = 0s
unknown_local_recipient_reject_code = 450
# extmail config here
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_transport = maildrop:
maildrop_destination_recipient_limit = 1
编辑mysql_virtual_alias_maps.cf
vi /etc/postfix/mysql_virtual_alias_maps.cf
内容如下:
user = extmail
password = extmail
hosts = localhost
dbname = extmail
table = alias
select_field = goto
where_field = address
编辑mysql_virtual_domains_maps.cf
vi /etc/postfix/mysql_virtual_domains_maps.cf
内容如下:
user = extmail
password = extmail
hosts = localhost
dbname = extmail
table = domain
select_field = description
where_field = domain
#additional_conditions = and backupmx ='0' and active ='1'
编辑mysql_virtual_mailbox_maps.cf
vi /etc/postfix/mysql_virtual_mailbox_maps.cf
内容如下:
user = extmail
password = extmail
hosts = localhost
dbname = extmail
table = mailbox
select_field = maildir
where_field = username
#additional_conditions = and active = '1'
5. 配置Courier-Authlib
安装Courier-Authlib
运行如下命令安装相关软件包
rpm -ivh RPMS/libtool-libs-1.5.6-4.EL4.2.i386.rpm
rpm -ivh RPMS/courier-authlib-0.60.2-1ext.i386.rpm
rpm -ivh RPMS/courier-authlib-devel-0.60.2-1ext.i386.rpm
rpm -ivh RPMS/courier-authlib-mysql-0.60.2-1ext.i386.rpm
编辑/etc/authlib/authmysqlrc文件,并将其内容清空,然后增加如下内容:
MYSQL_SERVER localhost
MYSQL_USERNAME extmail
MYSQL_PASSWORD extmail
MYSQL_SOCKET /var/lib/mysql/mysql.sock
MYSQL_PORT 3306
MYSQL_OPT 0
MYSQL_DATABASE extmail
MYSQL_USER_TABLE mailbox
MYSQL_CRYPT_PWFIELD password
MYSQL_UID_FIELD uidnumber
MYSQL_GID_FIELD gidnumber
MYSQL_LOGIN_FIELD username
MYSQL_HOME_FIELD homedir
MYSQL_NAME_FIELD name
MYSQL_MAILDIR_FIELD maildir
MYSQL_QUOTA_FIELD quota
MYSQL_SELECT_CLAUSE SELECT username,password,"",uidnumber,gidnumber,\
CONCAT('/home/domains/',homedir), \
CONCAT('/home/domains/',maildir), \
quota, \
name \
FROM mailbox \
WHERE username = '$(local_part)@$(domain)'
存盘退出后启动courier-authlib:
service courier-authlib start
如一切正常,命令行将返回如下信息:
Starting Courier authentication services: authdaemond
修改authdaemon socket目录权限
如果该目录权限不正确修改,maildrop及postfix等将无法正确获取用户的信息及密码认证:
chmod 755 /var/spool/authdaemon/
6.
安装Maildrop
安装maildrop
rpm -ivh RPMS/maildrop-2.0.4-1ext.i386.rpm
rpm -ivh RPMS/maildrop-man-2.0.4-1ext.i386.rpm
配置master.cf
为了使Postfix支持Maildrop,必须修改/etc/postfix/master.cf文件,注释掉原来的maildrop的配置内容,并改为:
maildrop unix - n n - - pipe
flags=DRhu user=vuser argv=maildrop -w 90 -d ${user}@${nexthop} ${recipient} ${user} ${extension} {nexthop}
配置main.cf
由于maildrop不支持一次接收多个收件人,因此必须在main.cf里增加如下参数:
maildrop_destination_recipient_limit = 1
最后重新启动postfix即可
注意事项:
1.如需重新编译Maildrop软件包,必须先获得其源码rpm包,并且必须先行安装courier-authlib及其devel软件包,否则编译后的maildrop将无法打开authlib支持。
2.maildrop RPM包安装时,会自动创建vuser用户及vgroup用户组,专门用于邮件的存储,vuser:vgroup的uid/gid都是1000,这与一般的邮件文档中提及用postfix用户存邮件不一样。因为postfix用户的uid一般都低于500,而Suexec模块编译时对UID/GID的要求是要大于500,因此使用postfix用户不能满足要求。其次,如果用Maildrop作为投递代理(MDA),以postfix身份投递的话,会导致postfix MTA错误。
四.配置Apache
编辑httpd.conf:
vi /etc/httpd/conf/httpd.conf
在730行左右,屏蔽掉AddDefaultCharset:
#AddDefaultCharset UTF-8
使apache开机默认启动:
chkconfig httpd on
虚拟主机设置
编辑/etc/httpd/conf/httpd.conf文件,在最后一行加上:
NameVirtualHost *:80
Include conf/vhost_*.conf
编辑/etc/httpd/conf/vhost_extmail.conf,里面定义虚拟主机的相关内容,包括主目录,以及ExtMail和ExtMan的相关配置,Suexec的设置等。
# VirtualHost for ExtMail Solution
ServerName mail.begindo.cn
DocumentRoot /var/www/extsuite/extmail/html/
ScriptAlias /extmail/cgi/ /var/www/extsuite/extmail/cgi/
Alias /extmail/ /var/www/extsuite/extmail/html/
ScriptAlias /extman/cgi/ /var/www/extsuite/extman/cgi/
Alias /extman/ /var/www/extsuite/extman/html/
# Suexec config
SuexecUserGroup vuser vgroup
重新启动apache:
service httpd restart
注意:此时重新启动apache会产生以下警告信息,可不必理会
Starting httpd: Warning: DocumentRoot [/var/www/extsuite/extmail/html/] does not exist