编译安装postfix-2.3.19

范堡 发布于 2011/10/14 10:34
阅读 1K+
收藏 1

http://de.postfix.org/ftpmirror/

建立安装所需的用户和组:

# groupadd -r -g 89 postfix
# useradd -r -u 89 -g 89 -d /var/spool/postfix -M -s /sbin/nologin postfix
# groupadd -r -g 90 postdrop

# tar xzf postfix-2.3.19.tar.gz -C /tmp
# cd /tmp/postfix-2.3.19/
# make makefiles CCARGS="-DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl -DUSE_TLS -I/usr/include -DHAS_LDAP -DHAS_PGSQL -I/usr/include/pgsql -DHAS_MYSQL -I/usr/include/mysql -DHAS_PCRE -I/usr/include -DHAS_SQLITE -I/usr/include" AUXLIBS="-L/usr/lib/sasl2 -lsasl2 -lssl -lcrypto -L/usr/lib -lldap -L/usr/lib -llber -L/usr/lib -lpq -L/usr/lib/mysql -lmysqlclient -lz -lm -L/usr/lib -lpcre -L/usr/lib -lsqlite3 -lpthread"
支持LDAP、MySQL、PostgreSQL、SQLite、Dovecot-SASL、 Cyrus-SASL、TLS和Perl兼容正则表达式PCRE。在编译之前要确保安装了相关扩展的安装包,包括lib包和devel开发包。详见 http://www.postfix.org/INSTALL.html。
# make
# make install
在安装过程中会有一些提问:

install_root: [/]
指定根目录,如果是默认的“/”,那么安装到系统上的文件位置和rpm安装方式的位置差不多。

tempdir: [/tmp/postfix-2.3.19]

config_directory: [/etc/postfix]

daemon_directory: [/usr/libexec/postfix]

command_directory: [/usr/sbin]

queue_directory: [/var/spool/postfix]

sendmail_path: [/usr/sbin/sendmail] /usr/sbin/sendmail.postfix

newaliases_path: [/usr/bin/newaliases] /usr/bin/newaliases.postfix

mailq_path: [/usr/bin/mailq] /usr/bin/mailq.postfix
如果根目录选择为“/”,以上三个文件就要改名,不然会覆盖原文件。事后可以将原来的文件重命名,在作个符号连接到这三个文件。

mail_owner: [postfix]

setgid_group: [postdrop]

html_directory: [no]

manpage_directory: [/usr/local/man] /usr/share/man

readme_directory: [no]


    Warning: you still need to edit myorigin/mydestination/mynetworks
    parameter settings in /etc/postfix/main.cf.

    See also http://www.postfix.org/STANDARD_CONFIGURATION_README.html
    for information about dialup sites or about sites inside a firewalled
    network.

    BTW: Check your /etc/aliases file and be sure to set up aliases
    that send mail for root and postmaster to a real person, then run
    /usr/bin/newaliases.postfix.
注意最后的警告信息。

# mv /usr/sbin/sendmail /usr/sbin/sendmail.old
# ln -s /usr/sbin/sendmail.postfix /usr/sbin/sendmail

# mv /usr/bin/newaliases /usr/bin/newaliases.old
# ln -s /usr/bin/newaliases.postfix /usr/bin/newaliases

# mv /usr/bin/mailq /usr/bin/mailq.old
# ln -s /usr/bin/mailq.postfix /usr/bin/mailq



编写启动脚本:
# vim /etc/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 0

[ -x /usr/sbin/postfix ] || exit 0
[ -d /etc/postfix ] || exit 0
[ -d /var/spool/postfix ] || exit 0

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 755 /etc/init.d/postfix
# chkconfig --add postfix
# chkconfig postfix on



检查支持的sasl:
# postconf -a
cyrus
dovecot

检查支持的外部扩展:
# postconf -m
btree
cidr
environ
hash
ldap
mysql
nis
pcre
pgsql
proxy
regexp
static
unix
加载中
0
mark35
mark35
postfix都2.8了,还用这么老的版本?
返回顶部
顶部