Chinaunix首页 | 论坛 | 博客
  • 博客访问: 937145
  • 博文数量: 119
  • 博客积分: 6248
  • 博客等级: 准将
  • 技术积分: 1419
  • 用 户 组: 普通用户
  • 注册时间: 2008-08-08 14:14
文章分类

全部博文(119)

文章存档

2014年(1)

2012年(1)

2011年(2)

2010年(22)

2009年(81)

2008年(12)

分类: LINUX

2009-10-27 16:36:20

(4)配置postfix以支持虚拟域和虚拟用户

         a、编辑/etc/postfix/main.cf,添加如下内容:

########################Virtual Mailbox Settings########################

virtual_mailbox_base = /var/mailbox

virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf

virtual_mailbox_domains= mysql:/etc/postfix/mysql_virtual_domains_maps.cf

virtual_alias_domains =

virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf

virtual_uid_maps = static:501   //501为你添加的postfix用户uid

virtual_gid_maps = static:501   //501为你添加的postfixgid

virtual_transport = virtual

maildrop_destination_recipient_limit = 1

maildrop_destination_concurrency_limit = 1

 

要注意的地方是 virtual_uid_mapsvirtual_gid_maps的值,它是postfix用户uidpostfix组的gid,与前面的文件/usr/local/authlib/etc/authlib/authmysqlrc"MYSQL_UID_FIELD""MYSQL_GID_FIELD"一定要保持一致

##########################QUOTA Settings######################## message_size_limit = 14336000

virtual_mailbox_limit = 20971520

virtual_create_maildirsize = yes

virtual_mailbox_extended = yes

virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql_virtual_mailbox_limit_maps.cf virtual_mailbox_limit_override = yes

virtual_maildir_limit_message = Sorry, the user's maildir has overdrawn his diskspace quota, please Tidy your mailbox and try again later.

virtual_overquota_bounce = yes

 

b、添加为支持虚拟域和虚拟用户所用到的配置文件,以下4个配置文件是不存在的,需要创建. 编辑/etc/postfix/mysql_virtual_alias_maps.cf ,添加如下内容:

 

user = extmail                 //虚拟用户名

 password = extmail             //虚拟用户密码

hosts = localhost              //虚拟的IP

dbname = extmail               //虚拟的数据库

table = alias                  //虚拟的数据库表

select_field = goto

where_field = address

 

c、 编辑/etc/postfix/mysql_virtual_domains_maps.cf ,添加如下内容:

user = extmail

password = extmail

hosts = localhost

dbname = extmail

table = domain

select_field = description

where_field = domain

 

d、 编辑/etc/postfix/mysql_virtual_mailbox_limit_maps.cf ,添加如下内容:

user = extmail

password = extmail

hosts = localhost

dbname = extmail

table = mailbox

select_field = quota

where_field = username

 

e、 编辑/etc/postfix/mysql_virtual_mailbox_maps.cf ,添加如下内容:

user = extmail

password = extmail

hosts = localhost

dbname = extmail

table = mailbox

select_field = maildir

where_field = username

 

说明:  1、这里用到的数据库及用户的建立可以后文中的extmail说明部分来实现,您可以参照那一部分来理解这里指定的数据库及其用户名等;

   2、以上新建文件亦可以从extman安装文件中获得,您也可以由此不用手动输入;

3、虚拟用户邮箱目录我这里沿用了/var/mailbox,你可以指定为别的目录,比如常见到的/var/spool/mail,或者/home/domains等;但如果这里做了修改,请在后文中用到时作了相应的修改;

 3. 注册Postfix为系统服务

        #chmod +x /etc/init.d/postfix

        #chkconfig --add  postfix

#chkconfig --level 35  postfix on

#service postfix start

五、安装配置courier-imap (用于实现pop3,imap收邮件功能)

1、安装courier-imap

        #tar -jxvf courier-imap-4.5.1.tar.bz2

        #cd courier-imap-4.5.1

        #./configure --prefix=/usr/local/courier-imap --enable-unicode --disable-root-check --with-trashquota --without-ipv6 

CPPFLAGS='-I/usr/local/courier-authlib/include' LDFLAGS='-L/usr/local/courier-authlib/lib/courier-authlib'

COURIERAUTHCONFIG='/usr/local/courier-authlib/bin/courierauthconfig'

#make

#make install

 

复制配置文件

#cd /usr/local/courier-imap/

#cp ./etc/imapd.dist ./etc/imapd

#cp ./etc/imapd-ssl.dist ./etc/imapd-ssl

#cp ./etc/pop3d.dist ./etc/pop3d

#cp ./etc/pop3d-ssl.dist ./etc/pop3d-ssl

 

配置Courier-IMAP,为用户提供pop3服务

#vi ./etc/pop3d

POP3DSTART=YES

注意:如果你想为用户提供IMAP服务,则需在"/usr/local/courier-imap/etc/imapd"文件中设置"IMAPDSTART=yes";其它类同;

 

设置开机启动

#cd /root/tools/postfix/courier-imap-4.5.1/

#cp courier-imap.sysvinit  /etc/init.d/courier-imapd

#chmod 755 /etc/init.d/courier-imapd

#chkconfig --add courier-imapd

#chkconfig --level 35 courier-imapd on

#service courier-imapd start

 

新建虚拟用户邮箱所在的目录

新建虚拟用户邮箱所在的目录,并将其权限赋予postfix用户:

#mkdir –pv /var/mailbox

#chown -R postfix /var/mailbox

 

重新配置SMTP 认证

#vi /usr/local/sasl2/lib/sasl2/smtpd.conf

确保其为以下内容:

pwcheck_method: authdaemond

log_level: 3

mech_list:PLAIN

LOGIN  authdaemond_path:/usr/local/courier-authlib/var/spool/authdaemon/socket

 

重新启动sasal服务

#killall -9 saslauthd

#/usr/local/sasl2/sbin/saslauthd -a shadow pam

 

六、安装配置webmail系统(extmail+extman

(extmail 用于实现web mail)

(extman 用于邮件服务器的后台管理)

1、安装extmail

#tar -zxvf extmail-1.0.9.tar.gz

#cp -rf extmail-1.0.9  /usr/local/apache/htdocs/extmail

#cd /usr/local/apache/htdocs/extmail

#cp webmail.cf.default  webmail.cf

 

2、配置extmail

#vi webmail.cf

部分修改选项的说明:

SYS_CONFIG = /usr/local/apache/htdocs/extmail/

SYS_LANGDIR = /usr/local/apache/htdocs/extmail/lang

SYS_TEMPLDIR = /usr/local/apache/htdocs/extmail/html

SYS_MESSAGE_SIZE_LIMIT = 5242880    //用户可以发送的最大邮件

SYS_USER_LANG = en_US               //语言选项,

可改作: SYS_USER_LANG = zh_CN

SYS_MAILDIR_BASE = /home/domains    //此处即为您在前文所设置的用户邮件的存放目录

可改作: SYS_MAILDIR_BASE = /var/mailbox

SYS_MYSQL_USER = db_user

SYS_MYSQL_PASS = db_pass

以上两句句用来设置连接数据库服务器所使用用户名、密码和邮件服务器用到的数据库,这里修改为:

SYS_MYSQL_USER = extmail

SYS_MYSQL_PASS = extmail

SYS_MYSQL_HOST = localhost  //指明数据库服务器主机名,这里默认即可 SYS_MYSQL_SOCKET = /var/lib/mysql/mysql.sock   //连接数据库的sock文件位置

这里修改为: SYS_MYSQL_SOCKET = /tmp/mysql.sock

SYS_MYSQL_TABLE = mailbox

SYS_MYSQL_ATTR_USERNAME = username

 SYS_MYSQL_ATTR_DOMAIN = domain

SYS_MYSQL_ATTR_PASSWD = password   //以上用来指定验正用户登录里所用到的表,以及用户名、域名和用户密码分别对应的表中列的名称这里默认即可

SYS_AUTHLIB_SOCKET = /var/spool/authdaemon/socket //此句用来指明authdaemo socket文件的位置这里修改为SYS_AUTHLIB_SOCKET = /usr/local/courier-authlib/var/spool/authdaemon/socket

 

3.  安装Extman

#tar -zxvf extman-1.0.0.tar.gz

#cp -r extman-1.0.0  /usr/local/apache/htdocs/extman

#cd /usr/local/apache/htdocs/extman

#mkdir /var/tmp/extman

#chown postfix.postfix /var/tmp/extman

#chown -R postfix.postfix cgi

 

4、配置Extman

#vi webman.cf

修改如下配置

SYS_CONFIG = /usr/local/apache/htdocs/extman/

SYS_LANGDIR = /usr/local/apache/htdocs/extman/lang

SYS_TEMPLDIR = /usr/local/apache/htdocs/extman/html

SYS_MAILDIR_BASE = /home/domains //此处即为您在前文所设置的用户邮件的存放目录

可改作: SYS_MAILDIR_BASE = /var/mailbox/

SYS_MYSQL_SOCKET = /var/lib/mysql/mysql.sock

 此处修改为: SYS_MYSQL_SOCKET = /tmp/mysql.sock

 SYS_SESS_DIR = /var/tmp/extman/

SYS_CAPTCHA_ON = 0 (关闭显示校验码或者安装perl-GD模块

 

5、建立数据库

使用extman源码目录下docs目录中的extmail.sqlinit.sql建立数据库:

#cd docs/

#mysql -u root -p

#mysql -u root -p

mysql>grant all privileges on extmai.* TO extmail@localhost IDENTIFIED BY 'extmail';

6、修改Apache编写虚拟主机

#vi /usr/local/apache/conf/httpd.conf

Include conf/extra/httpd-vhosts.conf   //去掉之前注释

 

#cd /usr/local/apache/conf/extra/

#vi httpd-vhosts.conf(内容修改如下)

NameVirtualHost *:80

    DocumentRoot "/usr/local/apache/htdocs/extmail/html/"

    ServerName  mail.lixin.org

    ScriptAlias /extmail/cgi/  /usr/local/apache/htdocs/extmail/cgi/

    Alias /extmail/  /usr/local/apache/htdocs/extmail/html/

    ScriptAlias /extman/cgi/  /usr/local/apache/htdocs/extman/cgi/

    Alias /extman/  /usr/local/apache/htdocs/extman/html/

   

         Options FollowSymLinks

         Allowoverride none

         Order allow,deny

         Allow from all

   

 

#service httpd stop

#service httpd start

 

安装Unix-Syslog前提系统已经安装了perl

#tar zxvf Unix-Syslog-0.100.tar.gz

#cd Unix-Syslog-0.100

#perl Makefile.PL

#make

#make install

 

安装DBD-Mysql

#tar zxvf DBD-mysql-4.012.tar.gz

#cd DBD-mysql-4.012

#perl Makefile.PL  --libs="-L/usr/local/mysql/lib/mysql -lmysqlclient -L/usr/lib -lz " --cflags=-I/usr/local/mysql/include/mysql  --mysql_config=/usr/local/mysql/bin/mysql_config

#make

#make install

 

在浏览器中输入以下连接进行访问:mail.lixin.org

进入邮件服务器,添加域与添加用户邮箱。默认管理帐号为:root@extmail.org 密码为:extmail*123*.

 

 

 

 

 

配置Mailgraph_ext

 

注意:安装以下软件之前,请确保你的系统已经安装了tcltcl-devellibartlibart-devel的相关的软件包.

 

需要安装3个包:Time::HiResFile::Tailrrdtool,其中前2个包可以去http://

Search.cpan.org,后一个包在

安装 Time::HiRes

   #tar zxvf Time-Hires-1.9707.tar.gz

   #cd Time-Hires-1.9707

   #perl Makefile.PL

   #make

   #make tetst

   #make install

 

安装 File::Tail

   #tar zxvf File-Tail-0.99.3.tar.gz

   #cd  File-Tail-0.99.3

   #perl Makefile.PL

   #make

   #make install

 

安装rrdtiil-1.2.23

  #tar zxvf rrdtool-1.2.23.tar.gz

  #cd rrdtool-1.2.23

  #./configure  --prefix=/usr/local/rrdtool

  #make

  #make install

 

创建必要的符号链接(Extman会到这些路径下找相关的库文件)

#ln  -sv /usr/local/rrdtool/lib/perl/5.8.5/i386-linux-thread-multi/auto/RRDs/RRDs.so  /usr/lib/perl5/5.8.5/i386-linux- thread-multi

#ln –sv /usr/local/rrdtool/lib/perl/5.8.5/RRDp.pm  /usr/lib/perl5/5.8.5/

#ln –sv /usr/local/rrdtool/lib/perl/5.8.5/i386-linux-thread-multi/RRDs.pm

 /usr/lib/perl5/5.8.5/

 

复制mailgraph_ext/usr/local,并启动之

#cp  -r /usr/local/apache/htdocs/extman/addon/mailgraph_ext  /usr/local

#/usr/local/mailgraph_ext/mailgraph-init start

#/usr/local/mailgraph_ext/qmonitor-init start

 

添加到自动启动行列

#echo “/usr/local/mailgraph_ext/mailgraph-init start”>>/etc/rc.local

#echo “/usr/local/mailgraph_ext/qmonitor-init start”>>/etc/rc.local

 

 

阅读(2507) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~