完整CentOS-Postfix邮件服务器建设 - 图文

更新时间:2023-10-07 01:37:01 阅读量: 综合文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

hac_ker@126.com

centos postfix extmail 安装和常见问题

1.. 安装

2.. 常见问题 (安装源码包courier-imap包)

操作系统 WebMail 系统 Web 账户管理后台 其它数据认证库 SMTP 认证库 POP3 认证库 CentOS 5.6 Extmail 1.1.0 Extman 1.0.0 courier-authlib 0.62..2 cyrus-sasl 2.1.22 CentOS和RHEL是一样的,而且升级免费 最新 邮件系统主程序 支持多语言、全部模板化,功能基本齐全 支持无限域名、无限用户 支持过滤和强大的功能 负责courier-imap,maildrop 的认证 标准的SASL实现库,支持courier authlib 邮件传输代理(MTA) Postfix 2.6.2 邮件投递代理(MDA) maildrop 2.0.4 courier-imap 4.5.0 Pop3 ,IMAP 认证功能

一、安装前准备

1.安装时加上mysql server ,其它以默认安装(如果安装时忘记安装mysql,可以运行 yum install mysql-server 来安装); 2.关闭防火墙; 3.关闭SELINUX

4.删除系统原来安好的sendmail # rpm -e --nodeps sendmail sendmail-cf

5.vi 使用高亮 # vi ~/.bashrc 中在alias下面另上一行 alias vi='vim' 后重启(这一步可有可无)

6.建立EMOS1.5 的YUM源

# vi /etc/yum.repos.d/EMOS-Base.repo #建立EMOS的库

# EMOS-Base.repo # # Created by ExtMail Dev Team: http://www.extmail.org/ # # $Id$ [EMOS-base] name=EMOS-Base baseurl=http://mirror.extmail.org/yum/emos/1.5/os/$basearch/ gpgcheck=0 priority=0 protect=0 hac_ker@126.com

[EMOS-update] name=EMOS-Updates baseurl=http://mirror.extmail.org/yum/emos/1.5/updates/$basearch/ gpgcheck=0 priority=0 protect=0 # yum clean all 保存退出后清空原来的记录

二、配置MTA—postfix

# yum install postfix #安装postfix 包

# postconf -n >/etc/postfix/main2.cf

# mv /etc/postfix/main.cf /etc/postfix/main.cf.bak # mv /etc/postfix/main2.cf /etc/postfix/main.cf

# vi /etc/postfix/main.cf #修改main.cf 配置文件

增加以下内容 # hostname mynetworks = 127.0.0.1 myhostname = mail.rookie.com mydestination = $mynetworks $myhostname # banner mail_name = Postfix - by extmail.org smtpd_banner = $myhostname ESMTP $mail_name # response immediately smtpd_error_sleep_time = 0s # Message and return code control message_size_limit = 5242880 mailbox_size_limit = 5242880 show_user_unknown_table_name = no # Queue lifetime control bounce_queue_lifetime = 1d maximal_queue_lifetime = 1d

hac_ker@126.com

三、配置courier-authlib

# yum install courier-authlib courier-authlib-mysql

修改authlib 配置文件

# rm -f /etc/authlib/authmysqlrc # vi /etc/authlib/authmysqlrc

MYSQL_SERVER localhost MYSQL_USERNAME extmail MYSQL_PASSWORD extmail MYSQL_SOCKET /var/lib/mysql/mysql.sock MYSQL_PORT 3306 MYSQL_OPT 0 MYSQL_DATABASE extmail MYSQL_USER_TABLE mailbox MYSQL_CRYPT_PWFIELD password MYSQL_UID_FIELD uidnumber MYSQL_GID_FIELD gidnumber MYSQL_LOGIN_FIELD username MYSQL_HOME_FIELD homedir MYSQL_NAME_FIELD name MYSQL_MAILDIR_FIELD maildir MYSQL_QUOTA_FIELD quota MYSQL_SELECT_CLAUSE SELECT username,password,\ CONCAT('/home/domains/',homedir), \\ CONCAT('/home/domains/',maildir), \\ quota, \\ name \\ FROM mailbox \\ WHERE username = '$(local_part)@$(domain)' 修改authmysqlrc 的权限和拥有者

# chown daemon.daemon /etc/authlib/authmysqlrc # chmod 660 /etc/authlib/authmysqlrc

修改authdaemonrc 以下内容 authmodulelist=\ authmodulelistorig=\ 启动

hac_ker@126.com

# service courier-authlib start

Starting Courier authentication services: authdaemond

修改authdaemon socket 目录权限,否则以下面的测试SMTP认证就不能通过 # chmod 755 /var/spool/authdaemon/

四、配置maildrop

# yum install maildrop

配置master.cf 为了使Postfix支持Maildrop,必须修改/etc/postfix/master.cf文件,注释掉原来的maildrop的配置内容,并改为: maildrop unix - n n - - pipe flags=DRhu user=vuser argv=maildrop -w 90 -d ${user}@${nexthop} ${recipient} ${user} ${extension} {nexthop}

配置main.cf 由于maildrop不支持一次接收多个收件人,因此必须在/etc/postfix/main.cf里增加如下参数: maildrop_destination_recipient_limit = 1

测试maildrop对authlib支持 # maildrop -v

注意事项:

1、如需重新编译Maildrop软件包,必须先获得其源码rpm包,并且必须先行安装courier-authlib及其devel软件包,否则编译后的maildrop将无法打开authlib支持。

2、 maildrop RPM包安装时,会自动创建vuser用户及vgroup用户组,专门用于邮件的存储,vuser:vgroup的uid/gid都是 1000,这与一般的邮件文档中提及用postfix用户存邮件不一样。因为postfix用户的uid一般都低于500,而Suexec模块编译时对 UID/GID的要求是要大于500,因此使用postfix用户不能满足要求。其次,如果用Maildrop作为投递代理(MDA),以postfix 身份投递的话,会导致postfix MTA错误。

五、配置apache

修改apache配置文件

# vi /etc/httpd/conf/httpd.conf 在最后一行加上

hac_ker@126.com

NameVirtualHost *:80 Include conf/vhost_*.conf

新建vhost_extmail.conf

# vi /etc/httpd/conf/vhost_extmail.conf # VirtualHost for ExtMail Solution ServerName mail.rookie.com DocumentRoot /var/www/extsuite/extmail/html/ ScriptAlias /extmail/cgi/ /var/www/extsuite/extmail/cgi/ Alias /extmail /var/www/extsuite/extmail/html/ ScriptAlias /extman/cgi/ /var/www/extsuite/extman/cgi/ Alias /extman /var/www/extsuite/extman/html/ # Suexec config SuexecUserGroup vuser vgroup

设置apache开机启动 # chkconfig httpd on

六、配置 extmail+extman

安装extmail 和extman 自己安装的时候需要yum -y install perl-Unix-Syslog # yum install extsuite-webmail extsuite-webman

# cp /var/www/extsuite/extmail/webmail.cf.default /var/www/extsuite/extmail/webmail.cf

# vi /var/www/extsuite/extmail/webmail.cf 修改以下两项 SYS_MYSQL_USER = extmail SYS_MYSQL_PASS = extmail

更新cgi目录权限 由于SuEXEC的需要,必须将cgi目录修改成vuser:vgroup权限: # chown -R vuser:vgroup /var/www/extsuite/extmail/cgi/ # chown -R vuser:vgroup /var/www/extsuite/extman/cgi/

链接基本库到Extmail

hac_ker@126.com

问题:

install_driver(mysql) failed: Can't locate DBD/mysql.pm in @INC (@INC contains: /data/www/extsuite/extmail/libs /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/5.8.8) at (eval 15) line 3. Perhaps the DBD::mysql perl module hasn't been fully installed, or perhaps the capitalisation of 'mysql' isn't right. Available drivers: DBM, ExampleP, File, Proxy, Sponge.

at /data/www/extsuite/extmail/libs/Ext/Auth/MySQL.pm line 45

解决:

yum install perl-DBD-MySQL

问题: DBI

connect('database=extmail;host=localhost;mysql_socket=/tmp/mysql.sock','extmail',...) failed:

Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) at /data/www/extsuite/extmail/libs/Ext/Auth/MySQL.pm line 45 解决:

数据库连接有问题

问题:

[root@CentOSX64 extmail]# /usr/sbin/authtest -s login postmaster@extmail.org extmail

Authentication FAILED: Input/output error [root@CentOSX64 extmail]#

查看日志信息:

Aug 8 14:26:09 CentOSX64 authdaemond: failed to connect to mysql server (server=localhost, userid=extmail): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

Aug 8 14:26:37 CentOSX64 postfix/trivial-rewrite[18169]: warning: connect to mysql server localhost: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

Aug 8 14:26:37 CentOSX64 postfix/trivial-rewrite[18169]: fatal: mysql:/etc/postfix/mysql_virtual_alias_maps.cf(0,lock|fold_fix): table lookup problem Aug 8 14:26:38 CentOSX64 postfix/smtpd[18060]: warning: problem talking to service rewrite: Success

hac_ker@126.com

Aug 8 14:26:38 CentOSX64 postfix/master[18054]: warning: process /usr/libexec/postfix/trivial-rewrite pid 18169 exit status 1

Aug 8 14:26:38 CentOSX64 postfix/master[18054]: warning: /usr/libexec/postfix/trivial-rewrite: bad command startup -- throttling

修改:

vim /etc/authlib/authmysqlrc

MYSQL_SOCKET /tmp/mysql.sock # echo \start\>> /etc/rc.d/rc.local

# echo \-v -d\>> /etc/rc.d/rc.local perl -e 'use MIME::Base64; print encode_base64(\

perl -e 'use MIME::Base64; print encode_base64(\

问题:

Connection closed by foreign host.

[root@CentOSX64 ~]# telnet localhost 25 Trying 127.0.0.1...

Connected to localhost.localdomain (127.0.0.1). Escape character is '^]'.

220 mail.extmail.org ESMTP Postfix - by extmail.org ehlo demo.domain.tld 250-mail.extmail.org 250-PIPELINING 250-SIZE 5242880 250-VRFY 250-ETRN

250-AUTH LOGIN PLAIN 250-AUTH=LOGIN PLAIN 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSN auth login

334 VXNlcm5hbWU6

cG9zdG1hc3RlckBleHRtYWlsLm9yZw== 334 UGFzc3dvcmQ6 ZXh0bWFpbA==

535 5.7.8 Error: authentication failed: generic failure

hac_ker@126.com

日志信息:

Aug 8 15:02:45 CentOSX64 postfix/smtpd[19406]: warning: SASL authentication failure: cannot connect to saslauthd server: No such file or directory

Aug 8 15:02:45 CentOSX64 postfix/smtpd[19406]: warning: CentOSX64[127.0.0.1]: SASL login authentication failed: generic failure

解决:

/usr/lib/sasl2/smtpd.conf 配置问题 文件的权限问题 /var/spool/authdaemon 文件的权限问题 /etc/authlib/authdaemon 配置问题

关于很多日志报拒绝情况下,检查权限的问题,多数情况 是SELinux搞的鬼,将SELinux关闭,重新启动机器再看一切运行正常

问题:

[root@CentOSX64 yum.repos.d]# yum install courier-imap Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile Setting up Install Process Resolving Dependencies

--> Running transaction check

---> Package courier-imap.x86_64 0:4.6.0-1 set to be updated

--> Processing Dependency: courier-authlib-devel >= 0.60.6.20080629 for package: courier-imap

--> Processing Dependency: libcourierauthsasl.so()(64bit) for package: courier-imap

--> Processing Dependency: libcourierauth.so()(64bit) for package: courier-imap

--> Finished Dependency Resolution

courier-imap-4.6.0-1.x86_64 from EMOS-base has depsolving problems --> Missing Dependency: libcourierauth.so()(64bit) is needed by package courier-imap-4.6.0-1.x86_64 (EMOS-base)

courier-imap-4.6.0-1.x86_64 from EMOS-base has depsolving problems --> Missing Dependency: courier-authlib-devel >= 0.60.6.20080629 is needed by package courier-imap-4.6.0-1.x86_64 (EMOS-base)

courier-imap-4.6.0-1.x86_64 from EMOS-base has depsolving problems --> Missing Dependency: libcourierauthsasl.so()(64bit) is needed by package courier-imap-4.6.0-1.x86_64 (EMOS-base)

Error: Missing Dependency: libcourierauth.so()(64bit) is needed by package courier-imap-4.6.0-1.x86_64 (EMOS-base)

Error: Missing Dependency: libcourierauthsasl.so()(64bit) is needed by

hac_ker@126.com

package courier-imap-4.6.0-1.x86_64 (EMOS-base)

Error: Missing Dependency: courier-authlib-devel >= 0.60.6.20080629 is needed by package courier-imap-4.6.0-1.x86_64 (EMOS-base) You could try using --skip-broken to work around the problem You could try running: package-cleanup --problems package-cleanup --dupes

rpm -Va --nofiles --nodigest

The program package-cleanup is found in the yum-utils package. [root@CentOSX64 yum.repos.d]#

解决:

不在使用courier-imap rpm 安装,尔使用tar.gz 安装

[root@CentOSX64 yum.repos.d]# find / -name libcourierauthsasl.so /usr/lib64/courier-authlib/libcourierauthsasl.so

[root@CentOSX64 yum.repos.d]# find / -name courier-authlib-devel [root@CentOSX64 yum.repos.d]# find / -name libcourierauth.so /usr/lib64/courier-authlib/libcourierauth.so [root@CentOSX64 yum.repos.d]#

http://download.chinaunix.net/do ... eID=1789&site=1 yum –y install courier-authlib-devel tar -jxvf courier-imap-4.1.2.tar.bz2 cd courier-imap-4.1.2 ./configure --prefix=/usr/local/courier-imap --with-redhat --enable-unicode --disable-root-check \\ --with-trashquota --without-ipv6 CPPFLAGS='-I/usr/courier-authlib/include' \\

COURIERAUTHCONFIG='/usr/bin/courierauthconfig' \\ CPPFLAGS='-I/usr/courier-authlib/include' make

make install cp /usr/local/courier-imap/etc/imapd.dist /usr/local/courier-imap/etc/imapd cp /usr/local/courier-imap/etc/imapd-ssl.dist /usr/local/courier-imap/etc/imapd-ssl cp /usr/local/courier-imap/etc/pop3d.dist /usr/local/courier-imap/etc/pop3d cp /usr/local/courier-imap/etc/pop3d-ssl.dist /usr/local/courier-imap/etc/pop3d-ssl 配置Courier-IMAP,为用户提供pop3服务: vi /usr/local/courier-imap/etc/pop3d POP3DSTART=yes

注:如果你想为用户提供IMAP服务,可以在\文件中设置\。

hac_ker@126.com

设置courier-imap开机自动运行:

cp courier-imap.sysvinit /etc/rc.d/init.d/imapd chmod 755 /etc/rc.d/init.d/imapd chkconfig --add imapd service imapd start

hac_ker@126.com

安装欢迎界面

hac_ker@126.com

选择“English”作为安装界面的语言

hac_ker@126.com

选择键盘类型

hac_ker@126.com

磁盘分区设置

hac_ker@126.com

磁盘分区设置请选择“定制分区”(自动和手动分区根据自己喜好选择

hac_ker@126.com

Disk Druid分区工具界面

hac_ker@126.com

建立“boot分区”

hac_ker@126.com

建立“Swap分区”

hac_ker@126.com

建立“home分区”

hac_ker@126.com

建立“根分区”

本文来源:https://www.bwwdw.com/article/d96d.html

Top