📄 1421.html
字号:
<A href="index.html" tppabs="http://www.linuxhero.com/docs/index.html">本站首页</A>
<font color="#FF6699">>></font>
<A href="type19.html" tppabs="http://www.linuxhero.com/docs/type19.html">email</A> | <A href="copyright.html" tppabs="http://www.linuxhero.com/docs/copyright.html">版权说明</A></font></DIV>
</TD>
<TD><IMG height=22 src="images/spacer.gif" tppabs="http://www.linuxhero.com/docs/images/spacer.gif" width=1
border=0></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=10 cellPadding=0 width="100%" bgColor=#ffffff
border=0>
<TR>
<TD>
<TABLE cellSpacing=0 cellPadding=3 width="100%" border=0>
<TR>
<TD vAlign=top align=middle width="60%">
<TABLE cellSpacing=0 cellPadding=0 width="100%"
background="images/back.gif" tppabs="http://www.linuxhero.com/docs/images/back.gif" border=0>
<TBODY>
<TR>
<TD vAlign=top width="80%">
<DIV align=center>
<FORM action="search.html" tppabs="http://www.linuxhero.com/docs/search.html" method=get>
</FORM>
<TABLE cellSpacing=0 cellPadding=0 width="95%"
border=0><TBODY>
<TR>
<TD background="images/bgi.gif" tppabs="http://www.linuxhero.com/docs/images/bgi.gif"
height=30></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=3 width="95%"
align=center border=0>
<TBODY>
<TR>
<TD>
<TABLE cellSpacing=0 cellPadding=3 width="100%"
border=0>
<TBODY>
<TR>
<TD vAlign=top>
<p><FONT class=normalfont><B><font color=blue>Postfix+Cyrus-IMAP+Cyrus-SASL+MySQL+IMP</font></B></FONT><BR><FONT class=smallfont color=#ff9900>2004-04-23 15:18 pm</FONT><BR><FONT class=normalfont>作者:llzqq<br>来自:Linux知识宝库<br>联系方式:无名<br><br>1. 安装说明<br>
这里以RedHat AS 3.0平台,安装AS3时选择Web Server、MySQL Database Server”、<br>
Development Tools和Kernel Development软件组,安装完AS3后需要额外安装的有:<br>
php-mysql-4.3.2-8.ent.i386.rpm和mysql-devel-3.23.58-1.i386.rpm,另外需要说明的是,我以<br>
下的安装过程中使用了我预先建立好的安装包和配置文件。大家可以在我的ftp下载<br>
ftp://test:123456@nero.3322.org/postfix/ ,下载这个目录里所有的文件到你的/home/pub/目录下,这样大家就可以不用修改下文中的有关路径直接安装就可以了。<br>
2.0. 配置MySQL<br>
2.1. 安装MySQL<br>
# cd /home/pub<br>
# rpm -ivh mysql-server-3.23.58-1.i386.rpm<br>
修改/etc/my.cnf,使之只监听在本地打环端口:<br>
# vi /etc/my.cnf<br>
在[mysqld]小节里面添加:<br>
bind-address=127.0.0.1<br>
并设置其开机时候自动运行:<br>
# chkconfig --level 35 mysqld on<br>
2.2. 运行MySQL<br>
启动MySQL:<br>
# /etc/init.d/mysqld start<br>
设置MySQL的root用户密码:<br>
# mysqladmin -u root password new_password<br>
2.3. 测试MySQL<br>
启动MySQL后,检查MySQL的运行情况:<br>
# pstree | grep mysqld<br>
|-safe_mysqld---mysqld<br>
应该有如下端口打开:<br>
# netstat -an | grep LISTEN<br>
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN<br>
2.4. 建立数据库<br>
# cd /home/pub<br>
修改我建好的数据库脚本注意替换脚本中的域名为你自己的域名然后创用户建数据库:<br>
# mysql --user=root --password=password < mail.sql<br>
在这个过程中创建了用户数据库,确定了每个用户的邮箱为50M并添加了用户“test”,密码是“123456”<br>
3.0. 安装pam_mysql<br>
3.1. 编译与安装<br>
编译pam_mysql:<br>
# cd /home/pub<br>
# tar -zxf pam_mysql-0.5.tar.gz<br>
# cd pam_mysql<br>
修改pam_mysql.c的源代码,去掉调试消息:<br>
# vi +54 pam_mysql.c<br>
将如下一行:<br>
#define DEBUG<br>
修改为:<br>
/* #define DEBUG */<br>
然后编译:<br>
# make<br>
# cp pam_mysql.so /lib/security<br>
<br>
3.2. 配置<br>
创建/etc/pam.d/mail,它用来支持Cyrus-IMAP的imap认证、pop认证和Postfix的smtp认证:<br>
# cd /etc/pam.d<br>
# echo auth sufficient pam_mysql.so user=mail passwd=secret host=localhost db=mail table=USER usercolumn=USERNAME passwdcolumn=PASSWORD crypt=1 sqllog=0 > /etc/pam.d/mail<br>
# echo account required pam_mysql.so user=mail passwd=secret host=localhost db=mail table=USER usercolumn=USERNAME passwdcolumn=PASSWORD crypt=1 sqllog=0 >> /etc/pam.d/mail<br>
# echo auth sufficient pam_unix_auth.so >> /etc/pam.d/mail<br>
# echo account sufficient pam_unix_acct.so >> /etc/pam.d/mail<br>
<br>
做个符号链接/etc/pam.d/imap,它用来支持Cyrus-IMAP的imap认证:<br>
# [ -f imap ] && mv imap imap.orig<br>
# ln -s mail imap<br>
同样创建/etc/pam.d/pop ,它用来支持Cyrus-IMAP的pop3认证:<br>
# [ -f pop ] && mv pop pop.orig<br>
# ln -s mail pop<br>
同样创建/etc/pam.d/smtp ,它用来支持Postfix的smtp auth认证:<br>
# [ -f smtp ] && mv smtp smtp.orig<br>
# ln -s mail smtp<br>
系统上可能已经存在了这些文件,将原来的改名备份或删除即可。<br>
4.0. 配置Cyrus-SASL<br>
4.1. 配置<br>
AS3默认安装的Cyrus-SASL可以满足这套邮件系统的需要,一般不必重新编译。<br>
设置Postfix使用SASL的saslauthd认证守护进程来支持smtp auth认证,并只打开了plain和login认证模块:<br>
# cd<br>
# echo pwcheck_method: saslauthd > /usr/lib/sasl2/smtpd.conf<br>
# echo mech_list: plain login >> /usr/lib/sasl2/smtpd.conf<br>
配置saslauthd使用PAM认证方案:<br>
# vi /etc/sysconfig/saslauthd<br>
内容如下:<br>
MECH=pam<br>
将saslauthd设置为自动运行:<br>
# chkconfig --level 35 saslauthd on<br>
4.2. 运行<br>
运行saslauthd守护进程:<br>
# /etc/rc.d/init.d/saslauthd start<br>
<br>
5.0. 安装Postfix<br>
5.1. 编译与安装<br>
如果你的系统上原来有sendmail,先将其停止并将其文件改名:<br>
# cd /home/pub<br>
# /etc/init.d/sendmail stop<br>
# chkconfig --level 35 sendmail off<br>
# mv /usr/bin/newaliases /usr/bin/newaliases.orig<br>
# mv /usr/bin/mailq /usr/bin/mailq.orig<br>
# mv /usr/sbin/sendmail /usr/sbin/sendmail.orig<br>
<br>
然后添加两个组:postfix和maildrop和一个用户:postfix<br>
# groupadd -g 400 postfix<br>
# groupadd -g 401 postdrop<br>
# useradd -u 400 -g 400 -c postfix -M -d/no/where -s/no/shell postfix<br>
这里的组和用户的ID是系统中未使用的ID。<br>
<br>
编译Postfix,并支持mysql和sasl:<br>
# tar -xvzf postfix-2.0.16.tar.gz<br>
# cd postfix-2.0.16<br>
# make -f Makefile.init makefiles 'CCARGS=-DUSE_SASL_AUTH -DHAS_MYSQL -I/usr/include/mysql -I/usr/include/sasl' 'AUXLIBS=-L/usr/lib/mysql -L/usr/lib/sasl2 -lmysqlclient -lsasl2 -lz -lm'<br>
# make install<br>
<br>
安装时,安装程序会提问一些问题,可以直接按回车采用默认值。<br>
给postfix用户做一个系统别名,并将超级用户的邮箱转发到一个普通用户。使用/etc/postfix/aliases别名数据库(把“nero.3322.org”改成你的域名):<br>
# cd /etc/postfix<br>
# echo 'root: test@nero.3322.org' >> /etc/postfix/aliases<br>
生成/etc/postfix/aliases别名数据库:<br>
# postalias /etc/postfix/aliases<br>
生成/etc/postfix/virtual的DB库:<br>
# postmap virtual<br>
<br>
5.2. 配置<br>
修改/etc/postfix/master.cf中的关于cyrus的配置,(cyrus的命令行和以前有不兼容的地方,确保你的cyrus的参数如下使用了-r ${sender}参数):<br>
修改/etc/postfix/master.cf的配置:<br>
使用已备份的文件:<br>
# cp /home/pub/master.cf /etc/postfix/master.cf<br>
<br>
修改/etc/postfix/main.cf的配置:<br>
修改我已建好的main.cf文件,改其中的nero.3322.org和3322.org为你自己的域主机名和域名,然后:<br>
# cp /home/pub/main.cf /etc/postfix/main.cf<br>
<br>
修改/etc/postfix/virtual.mysql的配置:<br>
使用已建好的文件:<br>
# cp /home/pub/virtual.mysql /etc/postfix/virtual.mysql<br>
<br>
修改/etc/postfix/filter.mysql的配置:<br>
使用已建好的文件:<br>
# cp /home/pub/filter.mysql /etc/postfix/filter.mysql<br>
<br>
5.3. 运行<br>
启动命令如下:<br>
# /usr/sbin/postfix start<br>
5.4. 测试Postfix<br>
启动Postfix后,首先检查日志/var/log/messages有无错误信息,然后检查进程,应该有如下进程存在:检查端口及进程:<br>
# pstree |grep master<br>
|-master-+-pickup<br>
接着检查端口,应该有如下端口打开:<br>
# netstat -an |grep LISTEN<br>
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN<br>
再检测SMTP服务是否正常:<br>
# telnet localhost 25<br>
Trying 127.0.0.1...<br>
Connected to localhost.<br>
Escape character is '^]'.<br>
220 mail.nero.3322.org ESMTP Postfix<br>
QUIT<br>
221 Bye<br>
Connection closed by foreign host.<br>
6.0. 安装Cyrus-IMAP<br>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -