需要前面LAMP(第五章课后试验环境搭建)支持。而且还需要第六章环境
 
《一》配置虚拟用户支持 —— MySQL
service mysqld start   //启动mysql
tar zxvf   /mnt/extman-0.2.5.tar.gz –C /usr/local
[root@mail LNS-SG7]# cd /usr/local/extman-0.2.5/docs
[root@mail docs]# mysql -u root -p < extmail.sql     //导入数据库
[root@mail docs]# mysql -u root -p < init.sql
《二》配置虚拟用户支持 —— postfix
 [root@mail ~]# vi /etc/postfix/main.cf
innet_interfaces = 192.168.1.4, 127.0.0.1
myhostname = mail.benet.com                
……
#mydestination = $mydomain, $myhostname         //这里需要手动注释掉
virtual_mailbox_base = /mailbox
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_uid_maps = static:1000
virtual_gid_maps = static:1000
 
[root@mail docs]# cp mysql_virtual_* /etc/postfix/   //将虚拟用户映射表样例文件复制到指定位置
 
《三》配置虚拟用户支持 —— SMTP认证
 [root@mail LNS-SG7]# tar -jxvf courier-authlib-0.60.2.tar.bz2 -C /usr/local/
[root@mail LNS-SG7]# cd /usr/local/courier-authlib-0.60.2/
[root@mail courier-authlib-0.60.2]# ./configure --prefix=/usr/local/courier-authlib --without-stdheaderdir --with-authmysql --with-mysql-libs=/usr/local/mysql/lib/mysql --with-mysql-includes=/usr/local/mysql/include/mysql && make && make install
[root@mail courier-authlib-0.60.2]# make install-configure
[root@mail courier-authlib-0.60.2]# vi /etc/ld.so.conf //将库文件添加到系统中
/usr/local/courier-authlib/lib/courier-authlib
[root@mail courier-authlib-0.60.2]# ldconfig          //刷新数据库
[root@mail courier-authlib-0.60.2]# cd /usr/local/courier-authlib/etc/authlib/   //修改主配置,authdaemonrc文件
 
[root@mail authlib]# cp authdaemonrc authdaemonrc.bak
[root@mail authlib]# vi authdaemonrc
authmodulelist="authmysql"    //只保留这些项
authmodulelistorig="authmysql" 
 
[root@mail authlib]# chmod -R 755 /usr/local/courier-authlib/var/spool/authdaemon/ //给予权限否则无法获得用户数据和密码
[root@mail authlib]# cp authmysqlrc authmysqlrc.bak
 
 
[root@mail authlib]# vi authmysqlrc
MYSQL_SERVER localhost                     mysql数据库服务器位置
MYSQL_USERNAME extmail                   数据库管理员帐户
MYSQL_PASSWORD   extmail                  数据库管理员帐户密码
MYSQL_SOCKET   /tmp/mysql.sock            mysql.sock文件位置
MYSQL_DATABASE   extmail                    虚拟用户数据库
MYSQL_USER_TABLE   mailbox              从mailbox表获得邮件帐户的信息
MYSQL_CRYPT_PWFIELD password         从pssword字段获得帐户密码
MYSQL_UID_FIELD uidnumber             从uidnumber字段获得映射的本地用户UID
MYSQL_GID_FIELD gidnumber               从gidnumber字段获得映射的本地组GID
MYSQL_LOGIN_FIELD username            从username字段获得帐户名称(带@后缀)
MYSQL_HOME_FIELD concat(‘/mailbox/’,homedir)          合并出用户的宿主目录完整路径
MYSQL_NAME_FIELD name                                               从name字段获得帐户名称(不带@后缀)
MYSQL_MAILDIR_FIELD concat(‘/mailbox/’,maildir)         合并出用户的完整邮件存储路径
 
[root@mail authlib]# cp /usr/local/courier-authlib-0.60.2/courier-authlib.sysvinit /etc/init.d/courier-authlib     //添加启动脚本
[root@mail authlib]# chmod 755 /etc/init.d/courier-authlib
[root@mail authlib]# chkconfig --add courier-authlib
[root@mail authlib]# chkconfig --level 35 courier-authlib on
[root@mail authlib]# service courier-authlib start
Starting Courier authentication services: authdaemond //启动成功
 
[root@mail authlib]# vi /usr/lib/sasl2/smtpd.conf //修改Cyrus sasl 配置
pwcheck_method:authdaemond       //将认证方式更改为authdaemond
authdaemond_path:/usr/local/courier-authlib/var/spool/authdaemon/socket    // 指定SOCKET文件位置
 
《四》配置虚拟用户支持 —— dovecot
 [root@mail authlib]# cp /etc/dovecot.conf /etc/dovecot.conf.bak
[root@mail authlib]# grep -v "#" /etc/dovecot.conf.bak | grep -v "^$" > /etc/dovecot.conf
[root@mail ~]# vi /etc/dovecot.conf
mail_location = maildir:/mailbox/%d/%n/Maildir //修改
……
auth default {
   mechanisms = plain
    passdb sql {                                //添加
        args = /etc/dovecot-mysql.conf
    }
    userdb sql {
        args = /etc/dovecot-mysql.conf
    }
*       2. 创建数据查询配置文件
[root@mail ~]# vi /etc/dovecot-mysql.conf                
driver = mysql
connect = host=localhost dbname=extmail user=extmail password=extmail
default_pass_scheme = CRYPT
password_query = SELECT username AS user,password AS password FROM mailbox WHERE username = '%u'                           
user_query = SELECT maildir, uidnumber AS uid, gidnumber AS gid FROM mailbox WHERE username = '%u'
*       3. 建立邮箱目录,并调整权限
[root@mail ~]# mkdir -p /mailbox/extmail.org/postmaster/Maildir/
[root@mail Maildir]# chown -R postfix:postfix /mailbox
[root@mail authlib]# dovecot      //查看dovecot运行情况
Fatal:Dovecotisalready running with PID 28607 (read from /usr/local/var/run/dovecot/master.pid)
[root@mail authlib]# kill 28607     //杀死dovecot                                    
[root@mail authlib]# /usr/local/sbin/dovecot -c /etc/dovecot.conf           //重新启动dovecot 
[root@mail authlib]# dovecot                                  
Fatal: Dovecot is already running with PID 7509 (read from /usr/local/var/run/dovecot/master.pid)
*       测试虚拟用户配置结果
[root@mail authlib]# cd /usr/local/courier-authlib/sbin/
[root@mail sbin]# ./authtest -s login postmaster@extmail.org extmail
Authentication succeeded.               //成功
*         使用 telnet 进行认证登录
[root@mail sbin]# printf "postmaster@extmail.org"   | openssl base64
cG9zdG1hc3RlckBleHRtYWlsLm9yZw==
[root@mail sbin]# printf "extmail" | openssl base64
ZXh0bWFpbA==
[root@mail ~]# telnet localhost 25
……
AUTH LOGIN
334 VXNlcm5hbWU6
cG9zdG1hc3RlckBleHRtYWlsLm9yZw==
334 UGFzc3dvcmQ6
ZXh0bWFpbA==
235 2.0.0 Authentication successful
QUIT
221 2.0.0 Bye
《五》部署Extmail邮件使用界面
[root@mail LNS-SG7]# tar -zxvf Unix-Syslog-1.1.tar.gz -C /usr/local/
[root@mail LNS-SG7]# tar -zxvf DBI-1.607.tar.gz -C /usr/local/
[root@mail LNS-SG7]# tar -zxvf DBD-mysql-4.011.tar.gz -C /usr/local/
 
[root@mail LNS-SG7]# cd /usr/local/Unix-Syslog-1.1/
[root@mail Unix-Syslog-1.1]# perl Makefile.PL
[root@mail Unix-Syslog-1.1]# make && make install
[root@mail local]# cd  /DBI-1.607/
[root@mail DBI-1.607]# perl Makefile.PL
[root@mail DBI-1.607]# make && make intall
[root@mail DBI-1.607]# cd ../DBD-mysql-4.011/
[root@mail DBD-mysql-4.011]# perl Makefile.PL && make && make install
 
*       2. 安装 extmail 程序套件
[root@mail LNS-SG7]# tar zxvf extmail-1.0.5.tar.gz -C /usr/local/apache2/htdocs/
[root@mail LNS-SG7]# cd /usr/local/apache2/htdocs/
[root@mail htdocs]# mv extmail-1.0.5/ extmail
[root@mail htdocs]# cd extmail/
[root@mail extmail]# chown -R postfix:postfix cgi
[root@mail extmail]# cp webmail.cf.default webmail.cf
[root@mail extmail]# vi /usr/local/apache2/htdocs/extmail/webmail.cf
SYS_CONFIG = /usr/local/apache2/htdocs/extmail/                   //程序根目录
SYS_LANGDIR = /usr/local/apache2/htdocs/extmail/lang             //语言包文件目录
SYS_TEMPLDIR = /usr/local/apache2/htdocs/extmail/html            //系统模板目录
SYS_MAILDIR_BASE = /mailbox
SYS_MYSQL_USER = extmail
SYS_MYSQL_PASS = extmail
SYS_MYSQL_DB = extmail                     
SYS_MYSQL_HOST = localhost
SYS_MYSQL_SOCKET = /tmp/mysql.sock                  // MySQL套接字文件位置
修改上述配置项
调整HTTP文件配置。添加虚拟主机
[root@mail ~]# vi /usr/local/apache2/conf/httpd.conf
NameVirtualHost 192.168.1.4
<VirtualHost 192.168.1.4>
    ServerName mail.benet.com
    DocumentRoot /usr/local/apache2/htdocs/extmail/html/
    ScriptAlias /extmail/cgi/ /usr/local/apache2/htdocs/extmail/cgi/
    Alias /extmail /usr/local/apache2/htdocs/extmail/html/
    SuexecUserGroup postfix postfix
</VirtualHost>
[root@mail ~]# /usr/local/apache2/bin/apachectl restart
 
 
修改WINDOWS的HOST文件
C:\WINDOWS\system32\drivers\etc\hosts
验证成功。下面部署Extman Web管理界面
[root@mail /]# cd /mnt/LNS-SG7
[root@mail LNS-SG7]# tar -zxvf GD-2.41.tar.gz -C /usr/local/
[root@mail LNS-SG7]# tar zxvf File-Tail-0.99.3.tar.gz -C /usr/local/
[root@mail LNS-SG7]# cd /usr/local/GD-2.41/
[root@mail GD-2.41]# perl Makefile.PL && make && make install
[root@mail GD-2.41]# cd ../File-Tail-0.99.3/
[root@mail File-Tail-0.99.3]# perl Makefile.PL && make && make install
安装rrdtool绘图引擎包
[root@mail File-Tail-0.99.3]# cd /mnt/LNS-SG7
[root@mail LNS-SG7]# rpm -ivh rrdtool-1.2.23-3.el5.i386.rpm
[root@mail LNS-SG7]# rpm -ivh rrdtool-perl-1.2.23-3.el5.i386.rpm
 
安装并配置EXTMAN套件
[root@mail LNS-SG7]# tar zxvf extman-0.2.5.tar.gz -C /usr/local/apache2/htdocs/
[root@mail LNS-SG7]# cd /usr/local/apache2/htdocs
[root@mail htdocs]# mv extman-0.2.5 extman
调整cgi子目录的属主属组
[root@mail htdocs]# chown -R postfix:postfix /usr/local/apache2/htdocs/extman/cgi
创建系统临时会话保存目录
[root@mail htdocs]# mkdir /tmp/extman/
[root@mail htdocs]# chown -R postfix:postfix /tmp/extman/
修改webman.cf配置文件
[root@mail extmail]# vi /usr/local/apache2/htdocs/extman/webman.cf     
SYS_CONFIG = /usr/local/apache2/htdocs/extman/
SYS_LANGDIR = /usr/local/apache2/htdocs/extman/lang
SYS_TEMPLDIR = /usr/local/apache2/htdocs/extman/html
SYS_MAILDIR_BASE = /mailbox
SYS_MYSQL_USER = webman
SYS_MYSQL_PASS = webman
SYS_MYSQL_DB = extmail
SYS_MYSQL_HOST = localhost
SYS_MYSQL_SOCKET = /tmp/mysql.sock
调整hhtpd.conf添加extman目录别名设置
[root@mail htdocs]# vi /usr/local/apache2/conf/httpd.conf
……
<VirtualHost 173.17.17.11>
    ServerName mail.benet.com
    DocumentRoot /usr/local/apache2/htdocs/extmail/html/
    ScriptAlias /extmail/cgi/ /usr/local/apache2/htdocs/extmail/cgi/
    Alias /extmail /usr/local/apache2/htdocs/extmail/html/
    ScriptAlias /extman/cgi/ /usr/local/apache2/htdocs/extman/cgi/
    Alias /extman /usr/local/apache2/htdocs/extman/html/
    SuexecUserGroup postfix postfix
</VirtualHost>
[root@mail ~]# /usr/local/apache2/bin/apachectl restart
登录验证吧。。。。。。只要没有都执行好了就可以的。
用户名root@extmail.org 密码 extmail*123*
 
*       4. 启用 mailgraph_ext 图形日志插件
[root@mail ~]# cd  /usr/local/apache2/htdocs/extman/addon/mailgraph_ext/
[root@mail mailgraph_ext]# mkdir /usr/local/mailgraph_ext/
[root@mail mailgraph_ext]# cp mailgraph_ext.pl qmonitor.pl  /usr/local/mailgraph_ext/
[root@mail mailgraph_ext]# ./mailgraph-init start
[root@mail mailgraph_ext]# ./qmonitor-init start