CentOS6.4 搭建 LNMP+Postfix+Dovecot+Postfixadmin+Roundcubemail 企业邮件环境

1.先下载安装软件包并搭建好 LNMP 环境(略)

2.编译安装postfix-2.9.3。
2.1创建postfix用户和组,且指定GID最好为大于1000的数值。
# groupadd -g 2525 postfix
# useradd -g postfix -u 2525 -s /sbin/nologin -M postfix
# groupadd -g 2526 postdrop
# useradd -g postdrop -u 2526 -s /sbin/nologin -M postdrop

2.2 编译安装postfix

# tar xf postfix-2.11.0.tar.gz
# cd postfix-2.11.0
更新makefile文件,添加mysql、sasl认证支持:
# make makefiles ‘CCARGS=-DHAS_MYSQL -I/usr/local/webserver/mysql/include -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl -DUSE_TLS ‘ ‘AUXLIBS=-L/usr/local/webserver/mysql/lib -lmysqlclient -lz -lm -L/usr/lib/sasl2 -lsasl2 -lssl -lcrypto’
备注:-DUSE_SASL_AUTH表示启用SASL认证
# make && make install
Install 的时候路径可以全部默认,也可以自己更改
生成二进制文件,提高服务器性能(重要)
# newaliases
添加启动脚本:
vim /etc/rc.d/init.d/postfix

#!/bin/bash
#
# 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

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ $NETWORKING = “no” ] && exit 3

[ -x /usr/sbin/postfix ] || exit 4
[ -d /etc/postfix ] || exit 5
[ -d /var/spool/postfix ] || exit 6

RETVAL=0
prog=”postfix”

start() {
# Start daemons.
echo -n $”Starting postfix: ”
/usr/bin/newaliases >/dev/null 2>&1
/usr/sbin/postfix start 2>/dev/null 1>&2 && success || failure $”$prog start”
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 $”$prog stop”
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 $”$prog reload”
RETVAL=$?
echo
return $RETVAL
}

abort() {
/usr/sbin/postfix abort 2>/dev/null 1>&2 && success || failure $”$prog abort”
return $?
}

flush() {
/usr/sbin/postfix flush 2>/dev/null 1>&2 && success || failure $”$prog flush”
return $?
}

check() {
/usr/sbin/postfix check 2>/dev/null 1>&2 && success || failure $”$prog check”
return $?
}

restart() {
stop
start
}

# See how we were called.
case “$1″ in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
reload)
reload
;;
abort)
abort
;;
flush)
flush
;;
check)
check
;;
status)
status master
;;
condrestart)
[ -f /var/lock/subsys/postfix ] && restart || :
;;
*)
echo $”Usage: $0 {start|stop|restart|reload|abort|flush|check|status|condrestart}”
exit 1
esac

exit $?

# chmod +x /etc/rc.d/init.d/postfix
# chkconfig –add postfix
# chkconfig postfix on
# service postfix start
Starting postfix: [ OK ]

检查服务是否开始监听端口
# sudo netstat -tupln
看到25端口开始监听并且程序名称为 master 则为成功

postfix文件配置规则:
1、在postfix的配置文件中,参数行和注释行是不能处在同一行中的;
2、任何一个参数的值都不需要加引号,否则,引号将会被当作参数值的一部分来使用;
3、每修改参数及其值后执行 postfix reload 即可令其生效;但若修改了inet_interfaces,则需重新启动postfix;
4、如果一个参数的值有多个,可以将它们放在不同的行中,只需要在其后的每行前多置一个空格即可, postfix会把第一个字符为空格或tab的文本行视为上一行的延续.

# vim /etc/postfix/main.cf #增加如下内容
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject_invalid_hostname,reject_non_fqdn_hostname,reject_unknown_sender_domain,reject_non_fqdn_sender,reject_non_fqdn_recipient,reject_unknown_recipient_domain,reject_unauth_pipelining,reject_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_security_options = noanonymous
smtpdsmtpdsmtpd_sasl_application_name = smtpd
smtpd_banner = Welcome to our $myhostname
ESMTP,Warning: Version not Available!

# vim /usr/lib/sasl2/smtpd.conf #添加下边两行
pwcheck_method: saslauthd
mech_list: PLAIN LOGIN

Dovecot 编译参数
CPPFLAGS=-I/usr/local/webserver/mysql/include LDFLAGS=-L/usr/local/webserver/mysql/lib ./configure –with-mysql –with-sql –with-ssl=openssl –with-pam –sysconfdir=/etc/

Related post

  1. NO IMAGE
  2. NO IMAGE
  3. NO IMAGE

    2021.05.23

    Ngrok 搭建指南
  4. NO IMAGE
  5. NO IMAGE
  6. NO IMAGE

There are no comment yet.

ABOUT

老赵的个人博客,关于 Mac, iPhone, iPad, iPod等产品的软件和硬件技术交流。也讨论Linux/UNIX技术,服务器运维技术等。

2025 年 1 月
 1234
567891011
12131415161718
19202122232425
262728293031  

Powerd by WordPress on Xserve
Xserve 2009
@2012-2024 HelloMac Copyright