Linux 版 (精华区)

发信人: wugang (网络之狼·卐卐卐卐), 信区: Linux
标  题: 建一个大容量的webmail系统
发信站: 哈工大紫丁香 (2001年01月04日11:49:41 星期四), 站内信件

谢顺华 [本站会员]

                                             
 

一、操作系统的选择
    
   
建议大家选用freebsd或linux,不要用solaris,solaris的编译器和GUN的不兼容,而且有
很多地方都怪怪的。
    DNS也要预先设置好。(MX记录)

二、必需的软件
    
   1、qmail (www.qmail.org)
   2、qmailldap (www.nrg4u.com)
   3、openldap  (www.openldap.org)
   4、sqwebmail (www.inter7.com/sqwebmail)
   5、imap(www.inter7.com/courierimap 可选)
   我们全部选用Open Source Certified,软件是the GPL license.其实大家不要怕是
free软件,比起一些
  
商业软件,不公布源代码,售价不菲,漏洞不断,补丁不停,他们要好的多。比如qmail
经过很多人测试,甚至qmail
  
的作者还悬赏$500美圆让人找漏洞。事实证明qmail是很安全的。比M$的E$应该好的多.

  
在论坛里我听有人说,ldap慢,我不知道怎样得到这个结果,ldap是专门为读来设计的,
应该比传统的关系数据库快
  
一个数量级以上。有人说ldap在一百万级以上查询会很慢,我没有很好的测试环境,不知
道具体的结果。但我相信,
   ldap应付我们一般的应用足以。
  
三、软件的安装

1.安装openldap.
  openldap安装比较容易,建议大家用stable版本。
 ( 好象大家对ldap还不是很熟,如果有时间,我再整理一些ldap的资料给大家。)
  修改slapd.conf:(主要如下)
    
    chemacheck     on
    database        ldbm
    suffix          "dc=96333, dc=com"
    rootdn          "cn=Manager, dc=96333, dc=com"
    rootpw           {crypt}xxxxxxxx (或者用明文)
   
   修改slapd.oc.conf:增加objectclass qmailUser;
     
     objectclass qmailUser
        requires
                objectclass,
                mail,
                uid
        allows
                mailMessageStore,
                homeDirectory,
                userPassword,
                mailAlternateAddress,
                qmailUID,
                qmailGID,
                mailQuota,
                mailHost,
                mailForwardingAddress,
                deliveryProgramPath,
                qmailDotMode,
                deliveryMode,
                mailReplyText,
                accountStatus,
   
    根据需要可以增加birthday,question,answer等属性。



2.解压qmail-1.03.tar.gz,安装qmaildap补丁。
  tar zvxf ../   qmail-1.03.tar.gz 
  patch -p1 < qmailldap-...
  
  编辑Makefile文件

   LDAPFLAGS=-DQLDAP_CLUSTER

   # Perhaps you have different ldap libraries, change them here
   LDAPLIBS=-L/usr/local/lib -lldap -llber
   # and change the location of the include files here
   LDAPINCLUDES=-I/usr/local/include


   # to make the Netscape download progress bar work with qmail-pop3d
   # uncomment the next line (allready done)
   MNW=-DMAKE_NETSCAPE_WORK 

   # to enable the auto-maildir-make feature uncomment the next line
   MDIRMAKE=-DAUTOMAILDIRMAKE

   # to enable the auto-homedir-make feature uncomment the next line
   HDIRMAKE=-DAUTOHOMEDIRMAKE

   # on most systems we need this to make checkpassword
   SHADOWLIBS=-lcrypt

   # to enable the possibility to log and debug imap and pop uncoment the
   # next line
   DEBUG=-DDEBUG
   # WARNING: you need NONE DEBUG auth_* to run with inetd

   # Just for me, make from time to time a backup
   BACKUPPATH=/backup/qmail-backup/qmail-ldap.`date "+%Y%m%d-%H%M"`.tar
   # STOP editing HERE !!!


  
  然后按正常的次序安装qmail(增加必要的用户,make setup check ,config-fast
your.full.host.name)
  
   qmail启动脚本:
   
   env - PATH="/var/qmail/bin:/usr/local/bin" \

   qmail-start ./Maildir/ | /usr/local/bin/setuidgid qmaill \
 
  /usr/local/bin/multilog t /var/log/qmail &


  smtp启动脚本:


    env - PATH="/var/qmail/bin:/usr/local/bin" \

    tcpserver -H -R -l$HOSTNAME -x /etc/tcp.smtp.cdb -c100 \

   -uqmailduid -gqmaildgid 0 25 \

   /var/qmail/bin/qmail-smtpd 2>&1 > /dev/null &

  pop3启动脚本:

 env - PATH="/var/qmail/bin:/usr/local/bin" \

tcpserver -H -R -l$HOSTNAME -c100 0 110 /var/qmail/bin/qmail-popup \

$HOSTNAME \

/var/qmail/bin/auth_pop /var/qmail/bin/qmail-pop3d Maildir &



3.sqwebmail的安装。
  安装用--with-authldap 参数即可。禁止其他的模块安装。 
 
sqwebmail系统有另外一个选择,可以安装成fastcgi(www.fastcgi.com),需要重新编译
apache.
 
fastcgi提供持续连接,不象cgi每次初始化都要重新启动,浪费系统资源。但sqwebmail
作者暗示
  我们用authdaemon提供更好的性能,不必用fastcgi.

  修改authldaprc文件,与ldap服务器相适应。

  LDAP_SERVER           192.168.0.10    
  LDAP_PORT             389
  LDAP_BASEDN           dc=96333, dc=com
  LDAP_BINDDN           cn=Manager, dc=96333, dc=com
  LDAP_BINDPW           xxxxxxx
  LDAP_MAIL             mail
  LDAP_DOMAIN           96333.com
  LDAP_HOMEDIR          mailmessagestore
  LDAP_FULLNAME         cn
  LDAP_CRYPTPW          cryptPassword

 
如果大家装过sqwebmail的,知道sqwebmail是个很优秀的free软件,但他也有一些不太满
意的地方,有些功能
 
也不够完善。幸运的是sqwebmail提供全部的源代码(用c写的),我们可以方便的修改以
适应我们的需求。
  不过需要大家有一定的C技能。我在另外的文章中再和大家探讨这个问题。

4。 增加邮件用户
    
  dn: uid=xie, dc=96333, dc=com
  uid: xie
  cn: xie shunhua
  sn: shunhua
  objectClass: top
  objectClass: person
  objectClass: inetOrgPerson
  objectClass: qmailUser
  mail: opi@96333.net
  mailHost: mail1.96333.net
  mailMessageStore: /mail/xie
  mailQuota: 1000000S,100C
  qmailUID: 1001
  qmailGID: 1001
  userPassword: {crypt}b28a87518a
 
   大家要注意,ldapuid,gid要有读写用户邮件目录的权限。

  php提供很多ldap函授,大家可以方便应用。
 
5。修改qmail控制文件
    
    ~control/ldapserver

 Space separated list of Hostnames or IP addresses of LDAP servers
 Required
 Example: ldap.nrg4u.com

~control/ldapbasedn

 The base DN from where the search in the LDAP tree begins
 Most times required
 Default: NULL
 Example: o=Internet Pipeline, c=CH
 Note: Referrals are ignored

~control/ldaplogin

 cn=Manager,dc=96333,dc=com

~control/ldappassword
  xxxx
 
~control/ldaplocaldelivery


~control/ldaprebind


~control/ldapcluster

~control/ldapuid
  501

~control/ldapgid
  501
  大家要注意,ldapuid,gid要有读写用户邮件目录的权限。
  
6.分布式处理和负载平衡。

  
我们可以把pop3、smtp、imap、web分别装在几台不同的机器上,用户的注册信息保存在
后台的ldap服务器上。
   用户的邮件装在NFS服务器上。
             
             -----       ------      ------     -------    ------    ------  

------   ------
             | web |     | web|      | pop |    | pop  |  | smtp |  | smtp
|  |imap|  | imap |
             ------      ------      -------    -------   -------   
-------  ------  --------
                |           |           |         |          |         |   
    |        |
                |           |           |         |          |         |      
  |       
|
                
|-----------|-------------------------------------------------------------
                            |           |           |           |
                            |           |           |           |
                            |           |           |           |
                        ---------     ------      ------      ------
                        | ldap  |    | ldap |     | NFS |     | NFS |
                        --------     -------      -------     -------


所有的web、pop、smtp、imap服务器是共有IP地址,ldap、nfs服务器是私有IP地址.

负载平衡通常有DNS轮循,web服务器重定向,NAT等,可以采用ip端口映射把25,110,80分
别映射到几台服务器上,
提供系统的负载均衡。在web服务器上装上mini
qmail,用qmqp把邮件传递到中心服务器上。如果不装mini qmail
可以把发送邮件的连接连接到smtp服务器上,在smtp上也需要装sqwebmail(sqwebmail调
用qmail-inject发信).
pop、smtp上装上正常qmail。

把用户所在的域加在local上,为了保持qmai-user一致,让qmail-lspawn查询,需把配置
文件修改一致,
然后运行qmail-newu.

linux提供的NFS服务器不是很好,为了获取更好的性能,推荐用bsd.
如果大家要用linux,可以参考http://nfs.sourceforge.net/ 

关于负载平衡,这牵涉到较多的方面,我在另外的文章中再和大家探讨。如果大家获得成
功,欢迎大家给我来信,
报告你们的成功,让我分享你们的成功,我将很乐于看到大家获得成功。如果安装中有问
题,欢迎大家和我在论坛里交流,
或者直接发信给我(xie@96333.net).我会尽量回复大家的信。





 
  
中国Linux论坛 版权所有  


--
             .                       *            .      .                     
       .              .    Go 天竺 !         .                                 
          ★               +++++++++            .              *               
              .                              .                                 
       *           ▁▂▃▄▅▆▇█▇▇▆▅▄▃▂▁▂▃▄▅▆▇█▇▇▆▅▄▃  
▁▂▃▄▅▆▇█▇▇▆▅▄▃▂▁▁▂▃▄▅▆▇█▇▇▆▅▄▃▂▂▃▄▅▆▃▂              Go!  天竺  @>>--,--'--- http://beauty.hit.edu.cn 

※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: king.hit.edu.cn]
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:207.993毫秒