疯狂老头版《CentOS 5.1下用源码编译安装ExtMail》的笔记订正(3)
2008-12-01 00:50:30 作者:龙飞 来源:龙飞网 浏览次数:0 网友评论 0 条
第三部分
(十)安装 DB 库文件
# rpm -ivh giflib-4.1.3-7.1.el5.1.i386.rpm
# rpm -ivh libgdiplus-1.2.5-1.el5.centos.i386.rpm
# rpm -ivh mono-core-1.2.4-2.el5.centos.i386.rpm
# rpm -ivh dbus-sharp-0.63-8.el5.centos.i386.rpm
# rpm -ivh dbus-sharp-devel-0.63-8.el5.centos.i386.rpm
可以简写成rpm -ivh dbus-sharp-*.rpm,这样可以一次性安装两个包
# rpm -ivh dbh-1.0.24-5.el5.centos.i386.rpm
# rpm -ivh dbh-devel-1.0.24-5.el5.centos.i386.rpm
可以简写成rpm -ivh dbh-*.rpm
# rpm -ivh dbus-glib-devel-0.70-5.i386.rpm
(十一)安装 postfix
postfix 需要使用到 pcre 软件包,因此我们需要先安装下面这两个软件包:
# rpm -Uvh pcre-6.6-2.el5_1.7.i386.rpm
# rpm -Uvh pcre-devel-6.6-2.el5_1.7.i386.rpm
可以简写成rpm -Uvh pcre-*.rpm
# /etc/init.d/sendmail stop
# chkconfig --level 0123456 sendmail off
# tar zxvf postfix-2.4.6.tar.gz
# cd postfix-2.4.6
# make tidy
# /usr/sbin/groupadd postdrop -g 101
# /usr/sbin/groupadd postfix -g 102 (如果原来系统中有该用户则不需要再建)
# /usr/sbin/useradd -d /var/spool/postfix -s /bin/true -u 100 -g postfix -G postdrop postfix
# make makefiles CCARGS="-DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/local/include/sasl" AUXLIBS="-L/usr/local/lib -lsasl2"
# make -f Makefile.init makefiles \
'CCARGS=-DHAS_MYSQL -I/usr/local/mysql/include/mysql' \
'AUXLIBS=-L/usr/local/mysql/lib/mysql -R/usr/local/mysql/lib/mysql \
-lmysqlclient -lz -lm'
# make
# make install
按照疯狂老头的写法,不知道为什么,命令无法执行,我参考了Postfix官方网站的写法,将原作者一个整句拆成两个句子,分别执行,就可以顺利往下继续。
===================================
install_root: [/]
tempdir: [/mnt/softs/postfix-2.4.6] /tmp
config_directory: [/etc/postfix]
daemon_directory: [/usr/libexec/postfix]
command_directory: [/usr/sbin]
queue_directory: [/var/spool/postfix]
sendmail_path: [/usr/sbin/sendmail]
newaliases_path: [/usr/bin/newaliases]
mailq_path: [/usr/bin/mailq]
mail_owner: [postfix]
setgid_group: [postdrop]
manpage_directory: [/usr/local/man]
===================================
中间有两个步骤,是问要不要安装一些文档文件的,疯狂老头忽略了,不过没有关系,这两个步骤不论选是还是选否都不影响安装,只是大家安装的时候必须要仔细对照看,切不可一路回车到底
# mv /etc/aliases /etc/aliases.old
# ln -s /etc/postfix/aliases /etc/aliases
生成别名二进制文件,这个步骤如果忽略,会造成 postfix 效率极低:
# echo 'root: admin@example.com'>>/etc/postfix/aliases
# /usr/bin/newaliases
# postconf -n > /etc/postfix/main2.cf
# mv /etc/postfix/main.cf /etc/postfix/main.cf.old
# mv /etc/postfix/main2.cf /etc/postfix/main.cf
# chown root.root /var/spool/postfix
# chmod 755 /var/spool/postfix
# vi /etc/postfix/main.cf
# hostname
mynetworks = 127.0.0.1
myhostname = mail.extmail.org
mydomain = extmai.com
myorigin = $mydomain
mydestination = $mynetworks $myhostname
# banner
mail_name = Postfix - by extmail.org
smtpd_banner = $myhostname ESMTP $mail_name
# response immediately
smtpd_error_sleep_time = 3s
unknown_local_recipient_reject_code = 550
# extmail config here
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_transport = maildrop:
# cp /var/www/extsuite/extman/docs/mysql_* /etc/postfix/
(需要将 ExtMail extman 包解压,见下文“CentOS 5.1 下用源码编译安装 ExtMail (第四部分)”;当然亦可以参照下面步骤创建)
编辑 mysql_virtual_alias_maps.cf
# vi /etc/postfix/mysql_virtual_alias_maps.cf
内容如下:
user = extmail
password = extmail
hosts = localhost
dbname = extmail
table = alias
select_field = goto
where_field = address
编辑 mysql_virtual_domains_maps.cf
# vi /etc/postfix/mysql_virtual_domains_maps.cf
内容如下:
user = extmail
password = extmail
hosts = localhost
dbname = extmail
table = domain
select_field = description
where_field = domain
#additional_conditions = and backupmx ='0' and active ='1'
编辑 mysql_virtual_mailbox_maps.cf
# vi /etc/postfix/mysql_virtual_mailbox_maps.cf
内容如下:
user = extmail
password = extmail
hosts = localhost
dbname = extmail
table = mailbox
select_field = maildir
where_field = username
#additional_conditions = and active = '1'
SMTP 认证需要透过 Cyrus-SASL,连接到 authdaemon 获取认证信息,编辑 /etc/postfix/main.cf,增加如下内容:
# vi /etc/postfix/main.cf
# smtpd related config
smtpd_recipient_restrictions =
permit_mynetworks,
permit_sasl_authenticated,
reject_non_fqdn_hostname,
reject_non_fqdn_sender,
reject_non_fqdn_recipient,
reject_unauth_destination,
reject_unauth_pipelining,
reject_invalid_hostname,
# SMTP AUTH config here
broken_sasl_auth_clients = yes
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_security_options = noanonymous
编辑 postfix 的启动脚本:
# vi /etc/rc.d/init.d/postfix
内容如下:
===============================================================
#!/bin/sh
#
# postfix Postfix Mail Transfer Agent
#
# chkconfig: 2345 80 30
# description: Postfix is a Mail Transport Agent, which is the program \
# that moves mail from one machine to another.
# processname: master
# pidfile: /var/spool/postfix/pid/master.pid
# config: /etc/postfix/main.cf
# config: /etc/postfix/master.cf
#
# $Revision: 2.4 $
#
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
[ -x /usr/sbin/postfix ] || exit 0
[ -d /etc/postfix ] || exit 0
[ -d /var/spool/postfix ] || exit 0
RETVAL=0
start() {
# Start daemons.
echo -n "Starting postfix: "
/usr/sbin/postfix start 2>/dev/null 1>&2 && success || failure
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/postfix
echo
return $RETVAL
}
stop() {
# Stop daemons.
echo -n "Shutting down postfix: "
/usr/sbin/postfix stop 2>/dev/null 1>&2 && success || failure
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/postfix
echo
return $RETVAL
}
reload() {
echo -n "Reloading postfix: "
/usr/sbin/postfix reload 2>/dev/null 1>&2 && success || failure
RETVAL=$?
echo
return $RETVAL
}
restart() {
stop
start
}
abort() {
/usr/sbin/postfix abort 2>/dev/null 1>&2 && success || failure
return $?
}
flush() {
/usr/sbin/postfix flush 2>/dev/null 1>&2 && success || failure
return $?
}
check() {
/usr/sbin/postfix check 2>/dev/null 1>&2 && success || failure
return $?
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
reload)
reload
;;
abort)
abort
;;
flush)
flush
;;
check)
check
;;
status)
status master
;;
condrestart)
# don't use /var/lock/subsys/postfix, check for postfix running directly
daemon_directory=$(postconf -h daemon_directory)
$daemon_directory/master -t 2>/dev/null && : || restart
;;
*)
echo "Usage: postfix {start|stop|restart|reload|abort|flush|check|status|condrestart}"
exit 1
esac
exit $?
===============================================================
# chmod 755 /etc/rc.d/init.d/postfix
也可以用chkconfig --add postfix将其加入服务行列
启动 postfix 服务:
#/etc/rc.d/init.d/postfix start
也可以写成service postfix start