邮件服务系列之怎样实现基于虚拟域和虚拟用户的认证过程

虚拟域和虚拟用户的认证过程

准备工作:

1、安装一些必要的rpm包

  1. # yum install perl-DBD-MySQL -y     #必须安装,因为mysql是编译安装的,这个不会自动安装  
  2. # yum install mysql-devel -y        #因为前面安装dovecot时,由于依赖关系系统自动安装了
  3. 一个mysql客户端为了不出错误,所以devel包也装了  
  4. # yum install pcre-devel -y     # 编译安装apache用到  

2、由于后面的Extmail需要用到web服务,所以要安装web服务,详细过程请见博客-手动搭建LAMP

 

下面正式开始配置过程:

一、编译安装courier-authlib-0.64.0

  1. 1、安装要用到的rpm包 
  2. [root@mail courier-authlib-0.64.0]# yum install mysql-devel 
  3. [root@mail courier-authlib-0.64.0]# yum install expect      #使用expect实现主机间通信的 
  4.  
  5. 查看和ldtl相关的包是否安装: 
  6. [root@mail courier-authlib-0.64.0]# yum list | grep ltdl   
  7. Unable to read consumer identity 
  8. libtool-ltdl.i386                           1.5.22-7.el5_4             Base      
  9. libtool-ltdl-devel.i386                     1.5.22-7.el5_4             Base      
  10. [root@mail courier-authlib-0.64.0]# yum install libtool-ltdl libtool-ltdl-devel -y 
  11.  
  12. ltdl: 动态模块加载器,courier-authlib需要用到,所以安装相关的包 
  13.  
  14. 2、编译安装courier-authlib-0.64.0 
  15. 备注:在RHEL5上要使用0.64.0及之前的版本,否则,可能会由于sqlite版本过低问题导致configure检查无法通过
  16. 或编译无法进行。 
  17.  
  18. [root@mail ~]# date 0505145813.00  # 同步一下时间
  19. Sun May  5 14:58:00 CST 2013 
  20. [root@mail ~]# date 
  21. Sun May  5 14:58:13 CST 2013 
  22. [root@mail ~]# tar xf courier-authlib-0.64.0.tar.bz2  
  23. [root@mail ~]# cd courier-authlib-0.64.0   
  24. [root@mail courier-authlib-0.64.0]#./configure \ 
  25.     --prefix=/usr/local/courier-authlib \ 
  26.     --sysconfdir=/etc \ 
  27.     --without-authpam \ 
  28.     --without-authshadow \ 
  29.     --without-authvchkpw \ 
  30.     --without-authpgsql \ 
  31.     --with-authmysql \ 
  32.     --with-sqlite-libs=/usr/lib 
  33.     --with-sqlite-include=/usr/include 
  34.     --with-mysql-libs=/usr/local/mysql/lib \ 
  35.     --with-mysql-includes=/usr/local/mysal/include \ 
  36.     --with-redhat \ 
  37.     --with-authmysqlrc=/etc/authmysqlrc \ 
  38.     --with-authdaemonrc=/etc/authdaemonrc \ 
  39.     --with-mailuser=postfix \ 
  40.     --with-mailgroup=postfix \ 
  41.     --with-ltdl-lib=/usr/lib \ 
  42.     --with-ltdl-include=/usr/include 
  43. [root@mail courier-authlib-0.64.0]# make 
  44. [root@mail courier-authlib-0.64.0]# make install 
  45.  
  46.  
  47. 安装完成后会在/usr/local/courier-authlib/目录下生成一个var/spool/authdaemon套接字文件,系统会 
  48. 通过这个套接字文件和进程建立联系,所以权限要改为755 
  49.  
  50. 备注:可以使用--with-authdaemonvar=/var/spool/authdaemon选项来指定进程套按字目录路径。 
  51.  
  52. [root@mail courier-authlib-0.64.0]# cd /usr/local/courier-authlib/var/  
  53. [root@mail spool]# ll 
  54. total 8 
  55. drwxr-x--- 2 postfix postfix 4096 Mar 31 04:41 authdaemon 
  56. [root@mail spool]# chmod 755 /usr/local/courier-authlib/var/spool/authdaemon 
  57. [root@mail spool]# ll 
  58. total 8 
  59. drwxr-xr-x 2 postfix postfix 4096 Mar 31 04:41 authdaemon 
  60.  
  61.  
  62. 在编译路径下复制几个配置文件 
  63. [root@mail ~]# cd courier-authlib-0.64.0 
  64. [root@mail courier-authlib-0.64.0]# cp /etc/authdaemonrc.dist  /etc/authdaemonrc 
  65. [root@mail courier-authlib-0.64.0]# cp /etc/authmysqlrc.dist  /etc/authmysqlrc 
  66.  
  67. 修改/etc/authdaemonrc 文件 
  68. [root@mail courier-authlib-0.64.0]# vim /etc/authdaemonrc 
  69. authmodulelist="authmysql"         #认证模块类型 
  70. authmodulelistorig="authmysql"     #支持认证的原始模块类型 
  71. daemons=10                         #进程数,这个自己随意指定
  72.  
  73.  
  74. 3、配置其通过mysql进行邮件帐号认证 
  75. 编辑/etc/authmysqlrc 为以下内容,其中2525,2525 为postfix 用户的UID和GID。 
  76. MYSQL_SERVER localhost 
  77. MYSQL_PORT 3306                 #指定你的mysql监听的端口,这里使用默认的3306 
  78. MYSQL_USERNAME  extmail         #这时为后文要用的数据库的所有者的用户名 
  79. MYSQL_PASSWORD  extmail         #密码 
  80. MYSQL_SOCKET  /tmp/mysql.sock   #mysql的套接字文件,如果是rpm包装的在/var/lib/mysql/mysql.lock 
  81. MYSQL_DATABASE  extmail         #虚拟用户放在哪个库中,这个库有extman自动创建 
  82. MYSQL_USER_TABLE  mailbox       #mysql的用户账号放在哪个表中,这个也是由extman生成   
  83. MYSQL_CRYPT_PWFIELD  password 
  84. MYSQL_UID_FIELD  '2525' 
  85. MYSQL_GID_FIELD  '2525' 
  86. MYSQL_LOGIN_FIELD  username 
  87. MYSQL_HOME_FIELD  concat('/var/mailbox/',homedir)    #定义用户邮箱地址   concat是一个内置函数
  88. MYSQL_NAME_FIELD  name  能将两个字符串连接起来当做一个来使用
    MYSQL_MAILDIR_FIELD  concat('/var/mailbox/',maildir)  
  89. 给courier-authlib提供SysV风格的服务脚本,并启动服务 
  90. [root@mail courier-authlib-0.64.0]# cp courier-authlib.sysvinit /etc/init.d/courier-authlib 
  91. [root@mail courier-authlib-0.64.0]# chmod +x /etc/init.d/courier-authlib 
  92. [root@mail courier-authlib-0.64.0]# chkconfig --add courier-authlib 
  93. [root@mail courier-authlib-0.64.0]# chkconfig --level 2345 courier-authlib on 
  94. [root@mail courier-authlib-0.64.0]# service courier-authlib start 
  95. Starting Courier authentication services: authdaemond 
  96.  
  97. 4、新建虚拟用户邮箱所在的目录,并将其权限赋予postfix用户: 
  98. [root@mail ~]# mkdir -p /var/mailbox 
  99. [root@mail ~]# chown -R postfix /var/mailbox 
  100.  
  101. 接下来重新配置SMTP 认证,编辑 /usr/lib/sasl2/smtpd.conf ,确保其为以下内容: 
  102. [root@mail ~]# vim /usr/lib/sasl2/smtpd.conf 
  103. pwcheck_method: authdaemond 
  104. mech_list: PLAIN LOGIN 
  105. authdaemond_path:/usr/local/courier-authlib/var/spool/authdaemon/socket   #套接字文件路径 
  106.  
  107. 由于要用到sasl,所以重启一下saslauthd服务; 
  108. [root@mail ~]# service saslauthd restart 
  109. Stopping saslauthd:                                        [  OK  ] 
  110. Starting saslauthd:                                        [  OK  ] 

二、让postfix支持虚拟域和虚拟用户

  1. 1、编辑/etc/postfix/main.cf,添加如下内容: 
  2.  
  3. [root@mail ~]# vim /etc/postfix/main.cf 
  4.  
  5. ########################Virtual Mailbox Settings######################## 
  6. virtual_mailbox_base = /var/mailbox 
  7. virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf 
  8. virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf 
  9. virtual_alias_domains = 
  10. virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf 
  11. virtual_uid_maps = static:2525 
  12. virtual_gid_maps = static:2525 
  13. virtual_transport = virtual 
  14. maildrop_destination_recipient_limit = 1 
  15. maildrop_destination_concurrency_limit = 1 
  16.  
  17. ##########################QUOTA Settings######################## 
  18. message_size_limit = 14336000 
  19. virtual_mailbox_limit = 20971520 
  20. virtual_create_maildirsize = yes 
  21. virtual_mailbox_extended = yes 
  22. virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql_virtual_mailbox_limit_maps.cf 
  23. virtual_mailbox_limit_override = yes 
  24. virtual_maildir_limit_message = Sorry, the user's maildir has overdrawn his diskspace quota, please Tidy your mailbox and try again later. 
  25. virtual_overquota_bounce = yes 
  26.  
  27.  
  28. 2、使用extman源码目录下docs目录中的extmail.sql和init.sql建立数据库: 
  29.  
  30. exman需要用到apache服务,所以请先安装httpd,这里是源码编译安装的http-2.4.4,编译过程 
  31. 请参考博客LAMP的搭建过程 
  32.  
  33. [root@mail ~]# tar xf extman-1.1.tar.gz  
  34. [root@mail ~]# cd extman-1.1 
  35. [root@mail extman-1.1]# ls 
  36. addon    cgi        contrib  docs  INSTALL  libs    README.fcgi  Version 
  37. AUTHORS  ChangeLog  daemon   html  lang     README  tools        webman.cf.default 
  38. [root@mail extman-1.1]# cd docs/ 
  39. [root@mail docs]# ls 
  40. backport        init.sql                      ldap_virtual_mailbox_maps.cf   mysql_virtual_limit_maps.cf 
  41. extmail.schema  ldap_virtual_alias_maps.cf    ldap_virtual_sender_maps.cf    mysql_virtual_mailbox_maps.cf 
  42. extmail.sql     ldap_virtual_domains_maps.cf  mysql_virtual_alias_maps.cf    mysql_virtual_sender_maps.cf 
  43. init.ldif       ldap_virtual_limit_maps.cf    mysql_virtual_domains_maps.cf  README.postfix 
  44. [root@mail docs]# sed -i 's@TYPE=MyISAM@ENGINE=InnoDB@g' extmail.sql  #改一下里面的引擎类型
  45. [root@mail docs]# mysql -uroot -p < extmail.sql 
  46. Warning: mysql: ignoring option '--named-commands' due to invalid value 'root' 
  47. Enter password:                                         #我这里的mysql有密码,你们的就没有了 
  48. [root@mail docs]# mysql -uroot -p < init.sql 
  49. Warning: mysql: ignoring option '--named-commands' due to invalid value 'root' 
  50. Enter password:  
  51.   
  52.  
  53. 3、授予用户extmail访问extmail数据库的权限 
  54.  
  55. [root@mail docs]# mysql -uroot -p 
  56. Warning: mysql: ignoring option '--named-commands' due to invalid value 'root' 
  57. Enter password:  
  58. Welcome to the MySQL monitor.  Commands end with ; or \g. 
  59. Your MySQL connection id is 20 
  60. Server version: 5.5.28-log Source distribution 
  61.  
  62. Type 'help;' or '\h' for help. Type '\c' to clear the buffer. 
  63.  
  64. mysql> GRANT all privileges on extmail.* TO extmail@localhost IDENTIFIED BY 'extmail'
  65. Query OK, 0 rows affected (0.00 sec) 
  66. mysql>  GRANT all privileges on extmail.* TO [email protected] IDENTIFIED BY 'extmail'
  67. Query OK, 0 rows affected (0.00 sec) 
  68.  
  69.  
  70. 4、提供配置文件 
  71.  
  72. [root@mail docs]# ls 
  73. backport        init.sql       ldap_virtual_mailbox_maps.cf   mysql_virtual_limit_maps.cf 
  74. extmail.schema  ldap_virtual_alias_maps.cf    ldap_virtual_sender_maps.
  75. mysql_virtual_mailbox_maps.cf 
  76. extmail.sql     ldap_virtual_domains_maps.cf  mysql_virtual_alias_maps.cf    mysql_virtual_sender_maps.cf 
  77. init.ldif       ldap_virtual_limit_maps.cf    mysql_virtual_domains_maps.cf  README.postfix 
  78. [root@mail docs]# cp mysql_virtual_* /etc/postfix/ 
  79. [root@mail docs]# cd /etc/postfix/ 
  80. [root@mail postfix]# ls 
  81. access             generic        main.cf.default              mysql_virtual_domains_maps.cf  relocated 
  82. aliases            header_checks  makedefs.out                 mysql_virtual_limit_maps.cf    TLS_LICENSE 
  83. bounce.cf.default  LICENSE        master.cf                    mysql_virtual_mailbox_maps.cf  transport 
  84. canonical          main.cf        mysql_virtual_alias_maps.cf  mysql_virtual_sender_maps.cf   virtual 
  85.  
  86.  
  87. 5、连接数据库查看
  88.  
  89. [root@mail postfix]# mysql -uroot  
  90. Warning: mysql: ignoring option '--named-commands' due to invalid value 'root' 
  91. Welcome to the MySQL monitor.  Commands end with ; or \g. 
  92. Your MySQL connection id is 23 
  93. Server version: 5.5.28-log Source distribution 
  94.  
  95. Type 'help;' or '\h' for help. Type '\c' to clear the buffer. 
  96.  
  97. mysql> show databases; 
  98. +--------------------+ 
  99. Database           | 
  100. +--------------------+ 
  101. | information_schema |  
  102. | extmail            |  
  103. | mysql              |  
  104. | performance_schema |  
  105. | test               |  
  106. | wpdb               |  
  107. +--------------------+ 
  108. rows in set (0.00 sec) 
  109.  
  110. mysql> use extmail 
  111. Database changed 
  112. mysql> show tables; 
  113. +-------------------+ 
  114. | Tables_in_extmail | 
  115. +-------------------+ 
  116. | alias             |  
  117. | domain            |  
  118. | domain_manager    |  
  119. | mailbox           |  
  120. | manager           |  
  121. +-------------------+ 
  122. rows in set (0.04 sec) 
  123.  
  124. mysql> select * from domain\G            #让查询的内容纵向显示 
  125. *************************** 1. row *************************** 
  126.               domain: extmail.org        #如果我们在domain这个表中添加lsq.com,他就给我们中
  127. 继邮件了,此时只给这个域中继邮件,这个域是sql脚本生成的 
  128.          description: virtualDomain for extmail.org        
  129.          hashdirpath: A0/B0 
  130.             maxalias: 50 
  131.             maxusers: 50 
  132.             maxquota: 1073741824 
  133.      maxnetdiskquota: 1073741824 
  134.            transport: NULL 
  135.           can_signup: 1 
  136.        default_quota: 5242880 
  137. default_netdiskquota: 5242880 
  138.       default_expire: 1y 
  139.         disablesmtpd: 0 
  140.          disablesmtp: 0 
  141.       disablewebmail: 0 
  142.       disablenetdisk: 0 
  143.          disableimap: 1 
  144.          disablepop3: 0 
  145.           createdate: 2007-02-14 15:10:04 
  146.           expiredate: 2010-11-08 
  147.               active: 1 
  148. 1 row in set (0.03 sec) 

三、配置dovecot,是dovecot也支持虚拟域和虚拟用户

  1. 1、修改postfix的配置文件 
  2.  
  3. [root@mail postfix]# vim /etc/dovecot.conf 
  4. mail_location = maildir:/var/mailbox/%d/%n/Maildir  #表示在/var/mailbox下有每一个域,
  5. 在每个域下又有每一个用户名命名的文件,而用户的邮件则在maildir目录中保存 
  6.  
  7.  
  8. %d: dovecot所支持的宏,表示域名 
  9. %n:dovecot所支持的宏,表示用户名 
  10.  
  11. 2、修改下面的内容,并启用相关选项: 
  12. auth default { 
  13.     mechanisms = plain 
  14.     passdb sql { 
  15.         args = /etc/dovecot-mysql.conf 
  16.     } 
  17.     userdb sql { 
  18.         args = /etc/dovecot-mysql.conf 
  19.     } 
  20.  
  21. 禁用如下选项: 
  22.     userdb passwd { 
  23.  
  24.     passwdb pam { 
  25.  
  26. 注意:禁用时,前后括弧都禁用才能禁用此选项 
  27.  
  28. 3、编辑/etc/dovecot-mysql.conf 
  29.  
  30. [root@mail postfix]# vim /etc/dovecot-mysql.conf 
  31.  
  32. driver = mysql 
  33. connect = host=/tmp/mysql.sock dbname=extmail user=extmail password=extmail 
  34. default_pass_scheme = CRYPT 
  35. password_query = SELECT username AS user,password AS password FROM mailbox WHERE username = '%u'  
  36. user_query = SELECT maildir, uidnumber AS uid, gidnumber AS gid FROM mailbox WHERE username = '%u' 
  37.  
  38. [root@mail postfix]# service dovecot restart 
  39. Stopping Dovecot Imap:                                     [  OK  ] 
  40. Starting Dovecot Imap:                                     [  OK  ] 
  41.  
  42. 上述表示dovecot认证用户的时候基于哪个账号密码去连接数据库并且到数据库的哪个库中的哪张表中去查找用户和密码 
  43. 从而验证账号和密码是否匹配 
  44.  
  45.  
  46. 说明:如果mysql服务器是本地主机,即host=localhost时,如果mysql.sock文件不是默认的/var/lib/mysql/mysql.sock 
  47. 可以使用host=“sock文件的路径”来指定新位置;例如,使用通用二进制格式或源码安装的MySQL,其sock文件位置为/tmp/mysql.sock, 
  48. 相应地,connect应按如下方式定义: 
  49.  
  50. connect = host=/tmp/mysql.sock dbname=extmail user=extmail password=extmail 
  51.  
  52. 如果使用rpm包安装的mysql,其connect按如下方式定义: 
  53.  
  54. connect = host=localhost dbname=extmail user=extmail password=extmail 

四、安装Extmail-1.2

  1. 1、解压缩extmail至网页所在目录下,并提供配置文件 
  2.  
  3. [root@mail ~]# tar xf extmail-1.2.tar.gz  
  4. [root@mail ~]# mkdir -p /web/vhosts/extsuite 
  5. [root@mail ~]# mv extmail-1.2 /web/vhosts/extsuite/extmail 
  6. [root@mail ~]# cp /web/vhosts/ 
  7. extsuite/ www1/     www2/      
  8. [root@mail ~]# cp /web/vhosts/extsuite/extmail/webmail.cf.default /web/vhosts/extsuite/extmail/webmail.cf 
  9.  
  10.  
  11. 我们这里的网页路径是/web/vhosts/ 与默认的不一致,所以修改配置文件 
  12. 2、修改主配置文件 
  13.  
  14. 把SYS_CONFIG = /var/www/extsuite/extmail/  改为  SYS_CONFIG = /web/vhosts/extsuite/extmail/ 
  15.  
  16. 把SYS_LANGDIR = /var/www/extsuite/extmail/lang  改为  SYS_LANGDIR = /web/vhosts/extsuite/extmail/lang 
  17.  
  18. 把SYS_TEMPLDIR = /var/www/extsuite/extmail/html  改为  SYS_TEMPLDIR = /web/vhosts/extsuite/extmail/html 
  19.  
  20.  
  21. 部分修改选项的说明: 
  22.  
  23. SYS_MESSAGE_SIZE_LIMIT = 5242880        #用户可以发送的最大邮件 
  24.  
  25. SYS_USER_LANG = en_US 语言选项,可改作:SYS_USER_LANG = zh_CN 
  26.  
  27. SYS_MAILDIR_BASE = /home/domains     此处即为您在前文所设置的用户邮件的存放目录 
  28.  
  29. 可改作: 
  30.  
  31. SYS_MAILDIR_BASE = /var/mailbox 
  32.  
  33. SYS_MYSQL_USER = db_user 
  34. SYS_MYSQL_PASS = db_pass 
  35.  
  36. 以上两句句用来设置连接数据库服务器所使用用户名、密码和邮件服务器用到的数据库,这里修改为: 
  37.  
  38. SYS_MYSQL_SOCKET = /var/lib/mysql/mysql.sock     rpm包安装的不用改了 
  39.  
  40. 由于我们这里的源码编译安装的mysql所以的改为: 
  41.  
  42. SYS_MYSQL_SOCKET = /tmp/mysql.sock 
  43.  
  44. SYS_MYSQL_USER = extmail 
  45. SYS_MYSQL_PASS = extmail 
  46.  
  47. SYS_MYSQL_HOST = localhost        #指明数据库服务器主机名,这里默认即可 
  48.  
  49. SYS_MYSQL_TABLE = mailbox 
  50. SYS_MYSQL_ATTR_USERNAME = username 
  51. SYS_MYSQL_ATTR_DOMAIN = domain 
  52. SYS_MYSQL_ATTR_PASSWD = password 
  53.  
  54. 以上用来指定验正用户登录里所用到的表,以及用户名、域名和用户密码分别对应的表中列的名称;这里默认即可 
  55.  
  56. SYS_AUTHLIB_SOCKET = /var/spool/authdaemon/socket 
  57.  
  58. 此句用来指明authdaemo socket文件的位置,这里修改为: 
  59.  
  60. SYS_AUTHLIB_SOCKET = /usr/local/courier-authlib/var/spool/authdaemon/socket 

五、配置apache

  1. 由于extmail要进行本地邮件的投递操作,故必须将运行apache服务器用户的身份修改为您的邮件投递代理的用户 
  2. 本例中打开了apache服务器的suexec功能,故使用以下方法来实现虚拟主机运行身份的指定。此例中的MDA为 
  3. postfix自带,因此将指定为postfix用户: 
  4.  
  5. [root@mail ~]# vim /etc/httpd/httpd.conf 
  6.  
  7. 1、定位至:DocumentRoot    禁用中心主机 
  8.  
  9.  
  10. 2、在配置文件尾部添加如下内容: 
  11.  
  12. <VirtualHost *:80> 
  13.     ServerName mail.magedu.com 
  14.     DocumentRoot /web/vhosts/extsuite/extmail/html/ 
  15.     ScriptAlias /extmail/cgi /web/vhosts/extsuite/extmail/cgi 
  16.     Alias /extmail /web/vhosts/extsuite/extmail/html 
  17.     SuexecUserGroup postfix postfix   #Suexec就表示运行某些服务时,不以系统指定的身份运行,而以suexec指定的身份运行 
  18. </VirtualHost> 
  19.  
  20. 修改 cgi执行文件属主为apache运行身份用户: 
  21.  
  22. [root@mail ~]# cd /web/vhosts/extsuite/extmail/ 
  23. [root@mail extmail]# ls 
  24. AUTHORS    CREDITS        dispatch_lig.sh  html     libs         README.filter    Version 
  25. cgi        dispatch.fcgi  FAQ              INSTALL  README       README.vpopmail  webmail.cf 
  26. ChangeLog  dispatch-init  globabook.cf     lang     README.fcgi  tools            webmail.cf.default 
  27.  
  28. [root@mail extmail]# chown -R postfix.postfix cgi/ /var/www/extsuite/extmail/cgi/ 
  29.  
  30. [root@mail extmail]# httpd -t        #检查配置文件语法问题 
  31.  
  32. 注意:如果您没有打开apache服务器的suexec功能,也可以使用以下方法解决: 
  33.  
  34. [root@mail ~]# vim /etc/httpd/httpd.conf 
  35.  
  36. 修改apache服务的运行者为postfix 
  37. User postfix 
  38. Group postfix 
  39.  
  40. <VirtualHost *:80> 
  41.     ServerName mail.magedu.com 
  42.     DocumentRoot /web/vhosts/extsuite/extmail/html/ 
  43.     ScriptAlias /extmail/cgi /web/vhosts/extsuite/extmail/cgi      #执行cgi脚本的目录 
  44.     Alias /extmail /web/vhosts/extsuite/extmail/html               #别名路径 
  45. </VirtualHost> 
  46.  
  47. 3、依赖关系的解决 
  48.  
  49. extmail将会用到perl的Unix::syslogd功能,您可以去http://search.cpan.org搜索下载原码包进行安装。 
  50.  
  51. [root@mail ~]# tar xf Unix-Syslog-1.1.tar.gz  
  52. [root@mail ~]# cd Unix-Syslog-1.1 
  53. [root@mail Unix-Syslog-1.1]# perl Makefile.PL 
  54. [root@mail Unix-Syslog-1.1]# make 
  55. [root@mail Unix-Syslog-1.1]# make install 
  56.  
  57. 4、启动apache服务 
  58. # service httpd start 

六、安装extman-1.1

  1. 1、安装及基本配置 
  2.  
  3. 由于前面用到了extman,已经解压过了,所以这了我们直接使用 
  4.  
  5. [root@mail ~]# mv extman-1.1 /web/vhosts/extsuite/extman 
  6.  
  7. 提供配置文件并修改配置文件以符合本例的需要: 
  8. [root@mail ~]# cd /web/vhosts/extsuite/extman/ 
  9. [root@mail extman]# ls 
  10. addon    cgi        contrib  docs  INSTALL  libs    README.fcgi  Version 
  11. AUTHORS  ChangeLog  daemon   html  lang     README  tools        webman.cf.default 
  12. [root@mail extman]# cp webman.cf.default webman.cf 
  13. [root@mail extman]# vim webman.cf 
  14.  
  15. 2、修改主配置文件 
  16.  
  17. 我们这里的网页路径是/web/vhosts/ 与默认的不一致,所以修改配置文件 
  18.  
  19. 把SYS_CONFIG = /var/www/extsuite/extmail/  改为  SYS_CONFIG = /web/vhosts/extsuite/extman/ 
  20.  
  21. 把SYS_LANGDIR = /var/www/extsuite/extmail/lang  改为  SYS_LANGDIR = /web/vhosts/extsuite/extman/lang 
  22.  
  23. 把SYS_TEMPLDIR = /var/www/extsuite/extmail/html  改为  SYS_TEMPLDIR = /web/vhosts/extsuite/extman/html 
  24.  
  25.  
  26. SYS_MAILDIR_BASE = /home/domains   此处即为您在前文所设置的用户邮件的存放目录,可改作: 
  27.  
  28. SYS_MAILDIR_BASE = /var/mailbox 
  29.  
  30. 修改 SYS_CAPTCHA_ON = 1     为   SYS_CAPTCHA_ON = 0 
  31.  
  32. SYS_CAPTCHA_ON =      # 是否开启验证码功能,我们这里不开启 
  33.  
  34.  
  35. SYS_DEFAULT_UID = 1000 
  36. SYS_DEFAULT_GID = 1000 
  37.  
  38. 此两处后面设定的ID号需更改为前而创建的postfix用户和postfix组的id号,本文使用的是2525 
  39. 因此,上述两项需要修改为: 
  40.  
  41. SYS_DEFAULT_UID = 2525 
  42. SYS_DEFAULT_GID = 2525 
  43.  
  44.  
  45. SYS_MYSQL_SOCKET = /var/lib/mysql/mysql.sock   # 这个选项如果使用rpm包安装的mysql就不用改了 
  46.  
  47. 我们这里是源码编译安装的,改为: 
  48.  
  49. SYS_MYSQL_SOCKET = /tmp/mysql.sock 
  50.  
  51. 3、连上mysql,创建extman用户,并赋予extman用户extmail库上对表的所有权限 
  52.  
  53. [root@mail extman]# mysql -uroot -p 
  54. Warning: mysql: ignoring option '--named-commands' due to invalid value 'root' 
  55. Enter password:  
  56. Welcome to the MySQL monitor.  Commands end with ; or \g. 
  57. Your MySQL connection id is 28 
  58. Server version: 5.5.28-log Source distribution 
  59.  
  60. Type 'help;' or '\h' for help. Type '\c' to clear the buffer. 
  61.  
  62. mysql> grant all privileges on extmail.* to webman@localost identified by 'webman'
  63. Query OK, 0 rows affected (0.43 sec) 
  64.  
  65. mysql> grant all privileges on extmail.* to [email protected] identified by 'webman'
  66. Query OK, 0 rows affected (0.00 sec) 
  67.  
  68. mysql> flush privileges;        #让mysql刷新授权表,重读授权表 
  69. Query OK, 0 rows affected (0.20 sec) 
  70.  
  71. mysql>  
  72.  
  73.  
  74. 而后修改cgi目录的属主和数组为postfix: 
  75.  
  76. [root@mail extman]# pwd 
  77. /web/vhosts/extsuite/extman 
  78. [root@mail extman]# chown -R postfix.postfix /web/vhosts/extsuite/extman/cgi 
  79.  
  80.  
  81. 在apache的主配置文件中Extmail的虚拟主机部分,添加如下两行: 
  82.  
  83. ScriptAlias /extman/cgi /web/vhosts/extsuite/extman/cgi 
  84. Alias /extman /web/vhosts/extsuite/extman/html 
  85.  
  86. 完后重启服务,让之生效: 
  87. [root@mail extman]# service httpd restart 
  88. Stopping httpd:                                            [  OK  ] 
  89. Starting httpd:                                            [  OK  ] 
  90.  
  91. 创建其运行时所需的临时目录,并修改其相应的权限: 
  92.  
  93. [root@mail extman]# mkdir -pv /tmp/extman 
  94. mkdir: created directory `/tmp/extman' 
  95. [root@mail extman]# chown -R postfix.postfix /tmp/extman 

好了,这是我们的邮件服务给予虚拟域、虚拟用户认证过程已经完工了,下面我们来试一下吧!

 

 

点击那个添加域,我们可以添加一个域,然后在这个域里申请两个用户,就可以用这两个用户,互相发送和接收邮件,大家都来试一试吧!

 下面就是怎样实现pops和imaps来实现邮件加密了,未完待续!

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章