我的一亩三分地 我就喜欢!
13fen  设为主页
 收藏本站
 
当前位置: > 一亩三分地:首页 > 操作系统 > 服务器 > MAIL服务器 > Postfix+Courier-IMAP+Cyrus-SASL+PAM_MySQL+MySQL安装
热门文章排行
热门文章排行 启动与关闭服务器(12-28)
服务器应用:用serv-u建立FTP一(11-16)
破解局域网内不能互访的六大经典问题(12-28)
Windows中IIS内FTP服务器高级配置(11-16)
怎样设置域名的DNS服务器(11-16)
精采文章排行
精采文章排行 在Windows Server 2003中为Web站点(11-16)
IP基础--DNS协定(11-16)
怎样设置域名的DNS服务器(11-16)
DNS—bind安装与配置的关键技术揭秘(11-16)
Exchange Server 服务器通讯端口(11-16)
技术专题推荐
网管论坛交流
 

Postfix+Courier-IMAP+Cyrus-SASL+PAM_MySQL+MySQL安装 

作者:佚名   来源:Linux 宝库   点击:   日期:2006-11-23


-->
基本思路:
courier-imap提供pop3服务,直接访问mysql
postfix的所有用户,别名和多域名支持均存储在mysql中
smtp auth使用了sasl,通过pam_mysql对mysql进行访问。

相关软件:
mysql-4.0.12.tar.gz
courier-imap-1.7.1.tar.bz2
cyrus-sasl-1.5.28.tar.gz
pam_mysql-0.5.tar.gz
postfix-2.0.6.tar.gz

安装MySQL,这个网上资料很多,如果有不清楚的,请去查文档。
#/usr/sbin/useradd mysql
#tar zvxf mysql-4.0.12.tar.gz
#cd mysql*
#./configure --prefix=/usr/local/mysql
#make
#make install
#scripts/mysql_install_db
#chown -R mysql.root /usr/local/mysql/var
#/usr/local/mysql/bin/mysqld_safe -u mysql &
#cd ..
好了,MySQL已经搞定了。

安装pam_mysql
#tar zvxf pam_mysql*gz
#cd pam_mysql*
将pam_mysql.c中第54行注释掉,/* #define DEBUG */
#make
#cp pam_mysql.so /lib/security
#cd ..

安装Cyrus-SASL
#tar zvxf cyrus-sasl*gz
#cd cyrus-sasl*
#./configure --disable-sample --disable-pwcheck --disable-cram --disable-digest --disable-krb4\
--disable-gssapi --disable-anon --enable-plain --enable-login
#make
#make install
#ln -s /usr/local/lib/sasl /usr/lib/sasl
#echo /usr/local/lib >> /etc/ld.so.conf
#echo /usr/local/lib/sasl >> /etc/ld.so.conf
#echo /usr/local/mysql/lib/mysql >> /etc/ld.so.conf
#/sbin/ldconfig
#echo pwcheck_method: pam > /usr/lib/sasl/smtpd.conf
#cd ..

安装Postfix
如果系统上有sendmail,请先将其停止,并备份sendmail的二进制文件和配置文件。
#tar zvxf postfix*gz
#cd postfix*
#/usr/sbin/groupadd postfix
#/usr/sbin/groupadd postdrop
#/usr/sbin/useradd -g postfix -d /dev/null -s /bin/false postfix
#make -f Makefile.init makefiles 'CCARGS=-DUSE_SASL_AUTH -DHAS_MYSQL -I/usr/local/mysql/include/mysql -I/usr/local/include' \
'AUXLIBS=-L/usr/local/mysql/lib/mysql -L/usr/local/lib/sasl -lmysqlclient -lsasl -lz -lm'
#make install
#cd ..

安装courier-imap
#tar jvxf courier-imap*bz2
#cd courier-imap*
#./configure --without-authpwd --without-authpam --without-authuserdb --without-authshadow\
--without-cram --without-chkpw --without-ldap --without-pgsql --without-authdaemon\
--without-authcustom --with-authmysql
#make
#make check
#make install
#make install-configure
#cd ..

创建数据库,表。表结构见下:
#/usr/local/mysql/bin/mysql
mysql>create database postfix;
mysql>exit;
#/usr/local/mysql/bin/mysql < /tmp/postfix.sql

#####cut from here#####(postfix.sql)
CREATE TABLE postfix_mailauth (
userid char(20) binary NOT NULL default '',
username char(60) NOT NULL default '',
domain char(50) NOT NULL default '',
uid smallint(5) unsigned NOT NULL default '12345',
gid smallint(5) unsigned NOT NULL default '12345',
clearpw char(20) binary NOT NULL default '',
home char(100) NOT NULL default '',
maildir char(150) NOT NULL default '',
quota char(100) NOT NULL default '',
last_access int(10) unsigned NOT NULL default '0',
status tinyint(3) unsigned NOT NULL default '1',
passwd_lastchanged int(10) unsigned NOT NULL default '0',
PRIMARY KEY (username),
KEY status (status)
) TYPE=MyISAM;

CREATE TABLE postfix_forward (
username varchar(50) NOT NULL default '',
domain varchar(40) NOT NULL default '',
forward_addr text NOT NULL,
PRIMARY KEY (username)
) TYPE=MyISAM;

CREATE TABLE postfix_transport (
domain varchar(50) NOT NULL default '',
transport varchar(8) NOT NULL default 'virtual:',
PRIMARY KEY (domain)
) TYPE=MyISAM;
#####cut end#####
其中的uid和gid的default值请设置为系统用户postfix的uid和gid

配置pam
在/etc/pam.d/下创建文件smtp,内容如下:
#####
auth sufficient pam_mysql.so user=your_userid passwd=your_password host=localhost db=postfix table=postfix_mailauth usercolumn=username passwdcolumn=clearpw crypt=0
account required pam_mysql.so user=your_userid passwd=your_password host=localhost db=postfix table=postfix_mailauth usercolumn=username passwdcolumn=clearpw crypt=0
auth sufficient pam_unix_auth.so
account sufficient pam_unix_acct.so
#####

编辑courier-imap配置文件/usr/lib/courier-imap/etc/authmysqlrc,设置访问mysql的一些参数,比较简单,参见注释就行。

编辑/etc/postfix/main.cf
一般的配置请参见文件内的注释,需要注意的是以下几处:
#####所有的帐号,别名均在数据库中
virtual_mailbox_domains = $mydomain, xxx.com,yyy.com
transport_maps = mysql:/etc/postfix/transport.cf
virtual_mailbox_base = /
virtual_uid_maps = mysql:/etc/postfix/uid.cf
virtual_gid_maps = mysql:/etc/postfix/gid.cf
virtual_mailbox_maps = mysql:/etc/postfix/users.cf
virtual_maps = mysql:/etc/postfix/forward.cf
#####注意这里的最后的/不能丢
home_mailbox = Maildir/
#####SASL
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
smtpd_recipient_restrictions = permit_mynetworks permit_sasl_authenticated permit_auth_destination reject
smtpd_sasl_security_options = noanonymous
smtpd_client_restrictions = permit_sasl_authenticated
broken_sasl_auth_clients = yes

#####uid.cf
user = your_userid
password = your_password
dbname = postfix
table = postfix_mailauth
select_field = uid
where_field = username
hosts = localhost

#####gid.cf
user = your_userid
password = your_password
dbname = postfix
table = postfix_mailauth
select_field = gid
where_field = username
hosts = localhost

#####transport.cf
user = your_userid
password = your_password
dbname = postfix
table = postfix_transport
select_field = transport
where_field = domain
hosts = localhost

#####forward.cf
user = your_userid
password = your_password
dbname = postfix
table = postfix_forward
select_field = forward_addr
where_field = username
hosts = localhost

#####users.cf
user = your_userid
password = your_password
dbname = postfix
table = postfix_mailauth
select_field = maildir
where_field = username
hosts = localhost

到此基本成功,剩下的写些php脚本,所有的事情(添加、删除、修改用户、别名、域名)都可以通过web来做。

注:上文中的your_userid和your_password是指访问mysql的用户名和密码。

#####boot pop3 service
/usr/lib/courier-imap/libexec/pop3d.rc start
#####boot postfix
/usr/sbin/postfix start

一点补充说明:

在编译pam_mysql的时候:
在make之前,编辑Makefile,在第10行将mysql的include路径加入;在第12行将mysql的lib路径加入。
第10行像这样: -Wshadow -pedantic -fPIC -I/usr/local/mysql/include
第12行像这样: export LD_D=gcc -shared -Xlinker -x -L/usr/local/mysql/lib/mysql -lz

安装courier-imap:需要将mysql的路径加入,否则不能configure成功(configure)
#export PATH=$PATH:/usr/local/mysql/bin
#./configure --without-authpwd --without-authpam --without-authuserdb --without-authshadow \
--without-cram --without-chkpw --without-authldap --without-authpgsql --without-authdaemon \
--without-authcustom --with-authmysql=/usr/local/mysql/lib/mysql




文章评论】 【收藏本文】 【推荐好友】 【打印本文】 【论坛讨论

   相关文章:
·Win2003下Exchange2003安装全图解二 ·处理外部邮件的Exchangeserver设置
·准备好升级你的Exchange2003 ·Exchange2000安装的系统需求
·安装秘诀:Exchange2000容量与拓朴计算器 ·安装秘诀:将现有的Exchange2000群集节点

   文章评论:(条)
  
 请留名: 匿名评论   点击查看所有评论 网管论坛
 

  责任编辑:一分  声明:刊登此文章是为了传递更多信息,文章内容仅供参考,转载请注明出处。