postfix-2.6.2 安装教程

postfix-2.6.2 安装教程
postfix-2.6.2 安装教程

1,为了能在putty中能显示中文,建议修改:/etc/sysconfig/i18n文件的内容:

修改内容如下:

LANG="zh_CN.gb2312"

修改好内容之后,退出putty ,重新登陆;

2,为了安装方便,请使用yum安装上诉软件;

修改/etc/yum.repos.d/Centos-Media.repo :

#######################################

[c5-media]

name=CentOS-$releasever - Media

baseurl=file:///media/CentOS/

file:///media/cdrom/

file:///media/cdrecorder/

file:///mnt/cdrom

gpgcheck=0

enabled=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

#######################################

注意:以上内容的格式一定要正确,不能有错误;

保存之后,新建文件夹cdrom;

#mkdir /mnt/cdrom

挂载光驱

#mount /dev/cdrom /mnt/cdrom

如果之前已经挂载过,为了方便建议先卸载;

#umount /dev/cdrom

做好以上步骤,可以使用yum 的方法查询光驱的RPM包进行安装了;方法如下:

yum --disablerepo=\* --enablerepo=\c5-media install –y 软件名

1,mysql-5.1.50

tar -zxvf mysql-5.1.50.tar.gz

cd mysql-5.1.50

groupadd mysql

useradd -g mysql mysql

yum --disablerepo=\* --enablerepo=\c5-media install -y ncurses-devel libtermcap libtermcap-devel ncurses-devel gcc gcc-c++

./configure --prefix=/usr/local/mysql

make

make install

拷贝mysql的配置文件:

cp support-files/https://www.360docs.net/doc/2c8236983.html,f /etc/https://www.360docs.net/doc/2c8236983.html,f

设置自启动

cp support-files/mysql.server /etc/rc.d/init.d/mysqld

chmod 775 /etc/rc.d/init.d/mysqld

chkconfig --add mysqld

Chkconfig mysqld on

安装完以后要初始化数据库,要是升级安装的请跳过

cd /usr/local/mysql

/usr/local/mysql/bin/mysql_install_db --user=mysql

chown -R root.

chown -R mysql var

chgrp -R mysql.

/usr/local/mysql/bin/mysqld_safe --user=mysql &

好了,至此mysql安装完毕,你可以这样起动你的mysql服务

#/etc/rc.d/init.d/mysqld start

添加 /usr/local/mysql/bin 到环境变量 PATH 中:

ln -s /usr/local/mysql/bin/mysql /sbin/mysql

ln -s /usr/local/mysql/bin/mysqladmin /sbin/mysqladmin

为了能让系统找到mysql,请运行如下命令

#PATH=$PATH:/opt/postfix/mysql/bin

#export PATH

#echo"/opt/postfix/mysql/lib/mysql">>/etc/ld.so.conf

#ldconfig

# ldconfig -v

日志管理

开启错误日志

如果不配置此信息,默认的错误日志在mysql的安装目录下的var目录

以计算机名字命名的ERR文件,https://www.360docs.net/doc/2c8236983.html,.err

添加 mysql-root 密码:

# /usr/local/mysql/bin/mysqladmin -u root password 新密码

安装之后这个方法只能使用一次,具体原因在查!

(注意:以上方式安装好 MySQL 后,其 mysql.sock 文件位于 /tmp/mysql 目录下。)安装 perl-DBI ,DBD::Mysql 和 Unix::syslogd

ExtMail 将会用到 perl 的 DBD::Mysql 和 Unix::syslogd 功能,您可以去

https://www.360docs.net/doc/2c8236983.html,搜索下载原码包进行安装。

# tar zxvf Unix-Syslog-1.1.tar.gz

# cd Unix-Syslog-1.1

# perl Makefile.PL

# make

# make install

yum --disablerepo=\* --enablerepo=\c5-media install perl-DBI

DBD-Mysql 目前最新版本为DBD-mysql-4.012,但它和系统中的 perl 结合使用时会造成 extmail 无法正常使用,因此我们采用 3 的版本:

# tar zxvf DBD-mysql-4.012.tar.tar.gz

# cd DBD-mysql-4.012

# perl Makefile.PL

perl Makefile.PL --mysql_config=/usr/local/mysql/bin/mysql_config

--with-mysql=/usr/local/mysql

# make

# make install

安装 Time::HiRes 和File::Tail和 rrdtool-1.2.26

安装 Time::HiRes

# tar zxvf Time-HiRes-1.9719.tar.tar.gz

# cd Time-HiRes-1.9719

# perl Makefile.PL

# make

# make install

安装File::Tail

# tar zxvf File-Tail-0.99.3.tar.gz

# cd File-Tail-0.99.3

# perl Makefile.PL

# make

# make install

安装 rrdtool-1.3.8

# tar zxvf rrdtool-1.3.8.tar.gz

# cd rrdtool-1.3.8

# yum --disablerepo=\* --enablerepo=\c5-media install intltool libxml2-devel cairo-devel NetworkManager-glib-devel pkgconfig iso-codes iso-codes-devel libnotify-devel pango pango-devel paps

# ./confiugre

# make

# make install

2,httpd-2.2.11

groupadd vmail -g 1001

useradd vmail -u 1001 -g 1001

tar -zxvf httpd-2.2.11.tar.gz

cd httpd-2.2.11

yum --disablerepo=\* --enablerepo=\c5-media install –y openssl-deve

./configure --prefix=/usr/local/httpd --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-rewrite --enable-mods-shared=most --enable-suexec --enable-cgi --enable-cigd --with-suexec-caller=vmail --with-suexec-docroot=/var/www --with-suexec-uidmin=1001 --with-suexec-gidmin=1001

make

make install

cp support/apachectl /etc/rc.d/init.d/httpd

chmod +x /etc/rc.d/init.d/httpd

chmod 775 /etc/rc.d/init.d/httpd

vi /etc/rc.d/init.d/httpd

增加中间的三行

#!/bin/sh

# Startup script for the Apache Web Server

# chkconfig: - 85 15

# description: Apache is a World Wide Web server.

# Licensed to the Apache Software Foundation (ASF) under one or more

如果不增加,在chkconfig --add httpd 会提示:

service httpd does not support chkconfig

httpd: 未被识别的服务

启动httpd

service httpd start

自动启动设置

chkconfig --add httpd

测试:

http://192.168.0.3

出现 It works! 就是正常;

3,php-5.3.0

安装php之前必须先安装如下软件,避免在便宜的时候报错,无法进行安装:

yum --disablerepo=\* --enablerepo=\c5-media install -y libc-client libc-client-devel openssl openssl-devel gd gd-devel perl-dbd perl-dbd-devel libxml2-devel libjpeg-devel libpng-devel libXpm-devel

tar -zxvf php-5.3.0.tar.gz

cd php-5.3.0

cp /usr/include/gd.h /usr/lib/gd.h

./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql

--with-mysqli=/usr/local/mysql/bin/mysql_config --with-apxs2=/usr/local/httpd/bin/apxs

--with-libxml-dir=/usr/include/libxml2/libxml --with-gd=/usr/lib

--with-png-dir=/usr/include/ --with-jpeg-dir=/usr/include/

--with-xpm-dir=/usr/include/X11 --with-zlib --enable-debug --enable-magic-quotes --enable-libgcc --enable-ftp --enable-mbstring=all --enable-sockets --with-gnu-ld --with-imap --with-kerberos --with-imap-ssl --with-openssl

make

make test

make install

配置相关文件使httpd支持php

//配置httpd.conf文件

[root@redhat php-5.2.3]# vi /etc/httpd/httpd.conf

User vmail

Group vmail

AddType application/x-httpd-php .php .phtml //第352行增加

AddType application/x-httpd-php-source .phps

//第174行

DirectoryIndex index.html index.html.var index.php index.htm //第209行

//第126行起增加以下内容

ServerName mail.188biz.gz

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

#SuexecUserGroup vmail vmail #如果开启了suexec的功能就需要这个配置

Alias /phpmyadmin /var/www/phpmyadmin

-----

暂时不用设置

//配置httpd-vhost.conff文件,以支持虚拟主机,先删除原有的27-43

行的内容,然后再最后增加以下内容

[root@redhat php-5.2.3]# vi /etc/httpd/extra/httpd-vhosts.conf

ServerName https://www.360docs.net/doc/2c8236983.html,

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

SuexecUserGroup vmail vmail

#service httpd restart

--------------------

/usr/local/httpd/bin/apachectl start

Warning: DocumentRoot [/var/www/extsuite/extmail/html/] does not exist

不存在的原因是还没建立相关文件,将在后面进行

4,phpmyadmin

这个安装比较方便,直接解压,然后把解压后得到的文件家移动到/usr/local/httpd/htdocs下就可以了!

tar -zxvf phpMyAdmin-3.2.0.1-all-languages.tar.gz

mv phpMyAdmin-3.2.0.1-all-languages /usr/local/httpd/htdocs/phpmyadmin

测试:

http://mail.188biz.gz/phpmyadmin

用户名:root

密码:188biz

以上用户名和密码是mysql的用户名和密码;安装之后mysql的root密码是空密码,而phpmyadmin是不允许空密码登陆的,则需要修改root密码请按如下方法修改:

5,安装IMAP

5.1 安装courier-authlib-0.63.0

tar -jxvf courier-authlib-0.63.0.tar.bz2

cd courier-authlib-0.63.0

useradd vmail

yum --disablerepo=\* --enablerepo=\c5-media install gdbm-devel

./configure --prefix=/usr/local/authlib --with-redhat --with-authmysql=yes

--with-mailuser=vmail --with-mailgroup=vmail

--with-mysql-libs=/usr/local/mysql/lib/mysql

--with-mysql-includes=/usr/local/mysql/include/mysql --without-stdheaderdir

注意:rpm安装的包需要使用如下的命令:

./configure --prefix=/usr/local/authlib --with-redhat --with-authmysql=yes

--with-mailuser=vmail --with-mailgroup=vmail --with-mysql-libs=/usr/lib/mysql

--with-mysql-includes=/usr/include/mysql --without-stdheaderdir

make

make install

make install-configure

配置courier-authlib-0.63.0:

1):更改相关配置文件

vim /usr/local/authlib/etc/authlib/authdaemonrc

authmodulelist="authmysql" //第27行

authmodulelistorig="authmysql" //第34行

DEBUG_LOGIN=2 //第75行

//此文件中请不要使用空格符,应使用TAB键,避免使用空格键!!!

vim /usr/local/authlib/etc/authlib/authmysqlrc

MYSQL_SERVER localhost //26行

MYSQL_USERNAME extmail //27行

MYSQL_PASSWORD extmail //28行

MYSQL_DATABASE extmail //68行

MYSQL_SOCKET /tmp/mysql.sock

//49行这里需要手动添加的,避免使用空格键,一定要使用TAB键!!

MYSQL_USER_TABLE mailbox //75行

MYSQL_CLEAR_PWFIELD password //84行

MYSQL_UID_FIELD '1001' //105行

MYSQL_GID_FIELD '1001' //111行

MYSQL_LOGIN_FIELD username //120行

MYSQL_HOME_FIELD concat('/var/mailbox/',maildir) //125行

MYSQL_NAME_FIELD name //131行

MYSQL_MAILDIR_FIELD concat('/var/mailbox/',maildir) //142行

MYSQL_QUOTA_FIELD concat(quota,'S') //157行

以上内容必须配置正确,不然会在pop3d的测试中会出错!

新建立一个用户,做如下测试,不通过的就调试这里的配置!和

/usr/local/authlib/var/spool/authdaemon 的权限问题!

一下内容需要在建立数据库,邮件帐户才可以做测试!

[root@a2billing authlib]# /usr/local/authlib/sbin/authtest -s test@https://www.360docs.net/doc/2c8236983.html, test Authentication FAILED: Operation not permitted//提示测试通过了!

3):共享链接库

[root@redhat courier-authlib-0.63.0]# echo "/usr/local/authlib/lib/courier-authlib" >> /etc/ld.so.conf

[root@redhat courier-authlib-0.63.0]# ldconfig

[root@redhat courier-authlib-0.63.0]# ldconfig -v

4):启动及加入到自动运行队列

将解压后得到的文件夹里面的启动脚本拷贝到系统自动启动的文件夹下,做自动启动;

[root@redhat courier-authlib-0.63.0]# cp courier-authlib.sysvinit

/etc/init.d/courier-authlib

[root@redhat courier-authlib-0.63.0]# chmod 755 /etc/init.d/courier-authlib

[root@redhat courier-authlib-0.63.0]# chkconfig --add courier-authlib

[root@redhat courier-authlib-0.63.0]# chkconfig --level 2345 courier-authlib on [root@redhat courier-authlib-0.63.0]# service courier-authlib start

Starting Courier authentication services: authdaemond

配置让其他用户也能访问

chmod a+rwx /usr/local/authlib/var/spool/authdaemon

5。2 安装courier-imap-4.8.1

tar -jxvf courier-imap-4.8.1.tar.bz2

cd courier-imap-4.8.1

export COURIERAUTHCONFIG=/usr/local/authlib/bin/courierauthconfig

./configure --prefix=/usr/local/imapd --with-redhat --disable-root-check

--with-trashquota --with-dirsync --with-mysql-libs=/usr/local/mysql/lib/mysql

--with-mysql-includes=/usr/local/mysql/include/mysql --with-authmysql

--with-authmysql=yes --disable-root-check

rpm 包安装的mysql如下:

./configure --prefix=/usr/local/imapd --with-mysql-libs=/usr/lib/mysql

--with-mysql-includes=/usr/include/mysql --with-authmysql=yes --disable-root-check

make

make install

make install-configure

配置courier-imap-4.8.1:

1):编辑配置文件启用pop3及imap

# vim /usr/local/imapd/etc/pop3d

POP3DSTART=YES //第140行

# vi /usr/local/imap/etc/imapd

IMAPDSTART=YES //第403行

2):启动及加入自动运行队列

一下命令可以拷贝一起然后运行:

cp courier-imap.sysvinit /usr/local/imapd/sbin/imapd

chmod +x /usr/local/imapd/sbin/imapd

/usr/local/imapd/sbin/imapd start

cp courier-imap.sysvinit /etc/rc.d/init.d/imapd

chmod 755 /etc/rc.d/init.d/imapd

chkconfig --add imapd

chkconfig --level 2345 imapd on

(九)安装 cyrus-sasl-2.1.22

可以采用RPM安装

cyrus-sasl cyrus-sasl-devel

要是已经安装好,直接配置

# rpm -qa|grep cyrus-sasl (把查找出来的包都删除了)

# rpm -e --nodeps cyrus-sasl-2.1.22-4 cyrus-sasl-plain-2.1.22-4 cyrus-sasl-lib-2.1.22-4 # rm -rf /usr/lib/sasl

# rm -rf /usr/lib/sasl2

# tar xzvf cyrus-sasl-2.1.23.ta r.gz

# cd cyrus-sasl-2.1.23

./configure --prefix=/usr/local/sasl2 --disable-anon -enable-plain --enable-login

--enable-sql --with-mysql=/usr/local/mysql

--with-mysql-includes=/usr/local/mysql/include/mysql

--with-mysql-libs=/usr/local/mysql/lib/mysql

--with-authdaemond=/usr/local/authlib/var/spool/authdaemon/socket

# make

# make install

2:共享链接库

[root@redhat cyrus-sasl-2.1.21]# ln -sv /usr/local/sasl2/lib/* /usr/lib

create symbolic link `/usr/lib/https://www.360docs.net/doc/2c8236983.html,' to `/usr/local/sasl2/lib/https://www.360docs.net/doc/2c8236983.html,' create symbolic link `/usr/lib/libsasl2.so' to `/usr/local/sasl2/lib/libsasl2.so' create symbolic link `/usr/lib/libsasl2.so.2' to `/usr/local/sasl2/lib/libsasl2.so.2' create symbolic link `/usr/lib/libsasl2.so.2.0.21' to

`/usr/local/sasl2/lib/libsasl2.so.2.0.21'

create symbolic link `/usr/lib/sasl2' to `/usr/local/sasl2/lib/sasl2'

[root@redhat cyrus-sasl-2.1.21]# ln -sv /usr/local/sasl2/lib/* /usr/local/lib

create symbolic link `/usr/local/lib/https://www.360docs.net/doc/2c8236983.html,' to `/usr/local/sasl2/lib/https://www.360docs.net/doc/2c8236983.html,' create symbolic link `/usr/local/lib/libsasl2.so' to `/usr/local/sasl2/lib/libsasl2.so' create symbolic link `/usr/local/lib/libsasl2.so.2' to

`/usr/local/sasl2/lib/libsasl2.so.2'

create symbolic link `/usr/local/lib/libsasl2.so.2.0.21' to

`/usr/local/sasl2/lib/libsasl2.so.2.0.21'

create symbolic link `/usr/local/lib/sasl2' to `/usr/local/sasl2/lib/sasl2'

[root@redhat cyrus-sasl-2.1.21]#ln -sv /usr/local/sasl2/include/sasl/*

/usr/local/include

create symbolic link `/usr/local/include/hmac-md5.h' to

`/usr/local/sasl2/include/sasl/hmac-md5.h'

create symbolic link `/usr/local/include/md5global.h' to

`/usr/local/sasl2/include/sasl/md5global.h'

create symbolic link `/usr/local/include/md5.h' to `/usr/local/sasl2/include/sasl/md5.h' create symbolic link `/usr/local/include/prop.h' to

`/usr/local/sasl2/include/sasl/prop.h'

create symbolic link `/usr/local/include/sasl.h' to

`/usr/local/sasl2/include/sasl/sasl.h'

create symbolic link `/usr/local/include/saslplug.h' to

`/usr/local/sasl2/include/sasl/saslplug.h'

create symbolic link `/usr/local/include/saslutil.h' to

`/usr/local/sasl2/include/sasl/saslutil.h'

[root@redhat cyrus-sasl-2.1.21]# mkdir -pv /var/state/saslauthd

mkdir: created directory `/var/state'

mkdir: created directory `/var/state/saslauthd'

[root@redhat cyrus-sasl-2.1.21]# echo "/usr/local/sasl2/lib" >> /etc/ld.so.conf

[root@redhat cyrus-sasl-2.1.21]# echo "/usr/local/sasl2/lib/sasl2" >> /etc/ld.so.conf [root@redhat cyrus-sasl-2.1.21]# ldconfig

[root@redhat cyrus-sasl-2.1.21]# ldconfig -v

3:启动及加入到自动运行队列

[root@redhat cyrus-sasl-2.1.21]# echo "/usr/local/sasl2/sbin/saslauthd -a shadow pam">>/etc/rc.local

[root@redhat cyrus-sasl-2.1.21]# /usr/local/sasl2/sbin/saslauthd -a shadow pam

重要!!!

4:新建配置文件

[root@redhat cyrus-sasl-2.1.21]# vi /usr/lib/sasl2/smtpd.conf

pwcheck_method:authdaemond

mech_list:PLAIN LOGIN

log_level:3

authdaemond_path:/usr/local/authlib/var/spool/authdaemon/socket

这里的 smtpd.conf如果是rpm包安装的,则要建立在/etc/sasl2目录下

这个路进:/usr/local/authlib/var/spool/authdaemon/socket

必须要能被访问到

因为postfix 的用户postfix 要访问这个文件,vmail也要访问这个文件!

所以:

chown -R postfix.vmail :/usr/local/authlib

这里postfix是用户,vmail是一个组

6,安装Postfix-2.6.2

tar -zxvf postfix-2.6.2.tar.gz

cd postfix-2.6.2

rpm -e --nodeps sendmail

useradd postfix

useradd postdrop

yum --disablerepo=\* --enablerepo=\c5-media install db4-devel

make -f Makefile.init makefiles 'CCARGS=-DHAS_MYSQL -I/usr/local/mysql/include/mysql

-DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/local/sasl2/include/sasl -I/usr/include

-DUSE_TLS -I-DUSE_TLS -I/usr/include/openssl' 'AUXLIBS=-L/usr/local/mysql/lib/mysql

-lmysqlclient -lz -lm -L/usr/local/sasl2/lib -lsasl2 -L/usr/lib -L/usr/lib -lssl -lcrypto'

rpm 包安装的

make makefiles 'CCARGS=-DHAS_MYSQL -I/usr/include/mysql -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl -I/usr/include/db4/ -DUSE_TLS -I/usr/include/openssl '

'AUXLIBS=-L/usr/lib/mysql -lmysqlclient -lz -lm -L/usr/lib/sasl2/ -lsasl2 -L/usr/lib

-L/usr/lib/openssl -lssl -lcrypto'

make

make install

采用回车即可!采用默认的配置!

2:建立邮件存放目录及备份旧文件

[root@redhat postfix-2.5-20071006]# mkdir -pv /var/mailbox

[root@redhat postfix-2.5-20071006]# chown -R vmail.vmail /var/mailbox

[[root@redhat postfix-2.5-20071006]# mv /etc/postfix/main.cf /etc/postfix/main.cf.old [root@redhat postfix-2.5-20071006]# mv /etc/postfix/master.cf /etc/postfix/master.cf.old

3:配置main.cf文件

//main.cf中的注解太多了,不如重新新建来得直观

vim /etc/postfix/main.cf

queue_directory = /var/spool/postfix

command_directory = /usr/sbin

daemon_directory = /usr/libexec/postfix

mail_owner = postfix

myhostname = mail.188biz.gz

mydomain = 188biz.gz

myorigin = $mydomain

inet_interfaces = all

mydestination =

unknown_local_recipient_reject_code = 550

mynetworks = 192.168.0.0/24, 127.0.0.0/8

############################CYRUS-SASL########################

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 = $mydomain

smtpd_sasl_security_options = noanonymous

smtpd_sasl_application_name = smtpd

smtpd_banner = Welcome to our $myhostname ESMTP,Warning: Version not Available!

#############################SASL-END##############################

#############################Virtual Mailbox Settings################

virtual_mailbox_base=/var/mailbox/

virtual_mailbox_maps=mysql:/etc/postfix/mysql/mysql_virtual_mailbox_maps.cf

virtual_mailbox_domains=mysql:/etc/postfix/mysql/mysql_virtual_domains_maps.cf

virtual_alias_domains=

virtual_alias_maps=mysql:/etc/postfix/mysql/mysql_virtual_alias_maps.cf

virtual_uid_maps=static:1001

virtual_gid_maps=static:1001

virtual_transport=maildrop:

maildrop_destination_recipient_limit=1

maildrop_destination_concurrency_limit=1

#################################Mailbox END###########################

#################################Quota Settings########################

message_size_limit=1433600

virtual_mailbox_limit=20791520

virtual_create_maildirsize=yes

virtual_mailbox_extended=yes

virtual_mailbox_limit_maps=mysql:/etc/postfix/mysql/virtual_mailbox_limit_override=yes virtual_maildir_limit_message=User's maildir has overdrawn his diskspace quota,try again later.

virtual_overquota_bounce=yes

################################Quota END############################

################################Amavis Start##########################

content_filter=amavisfeed:[127.0.0.1]:10024

max_use=10

################################Amavis END###########################

debug_peer_level = 2

debugger_command =

PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin

xxgdb $daemon_directory/$process_name $process_id & sleep 5

sendmail_path = /usr/sbin/sendmail

newaliases_path = /usr/bin/newaliases

mailq_path = /usr/bin/mailq

setgid_group = postdrop

html_directory = /var/www/postfix_html

manpage_directory = /usr/local/postfix/man

sample_directory = /etc/postfix

编辑master.cf

# vi /etc/postfix/master.cf

启用如下两行

maildrop unix - n n - - pipe

flags=DRhu user=vmail argv=/usr/local/bin/maildrop -d ${recipient}

注意:定义transport的时候,即如上两行中的第二行,其参数行[color=Red]必须以空格开头

[/color],否则会出错。

测试SMTP:

启动postfix

/var/log/maillog有错误日志

Jul 23 12:55:18 mail postfix/smtpd[3443]: warning: dict_nis_init: NIS domain name not set - NIS lookups disabled

Jul 23 12:55:18 mail postfix/smtpd[3443]: fatal: parameter "smtpd_recipient_restrictions": specify at least one working instance of: check_relay_domains, reject_unauth_destination, reject, defer or defer_if_permit

Jul 23 12:55:19 mail postfix/master[3439]: warning: process /usr/libexec/postfix/smtpd pid 3443 exit status 1

Jul 23 12:55:19 mail postfix/master[3439]: warning: /usr/libexec/postfix/smtpd: bad command startup -- throttling

在vmain.cf上添加这个配置:可以解决!

alias_maps=mysql:/etc/postfix/mysql/mysql_virtual_alias_maps.cf

5:添加为支持虚拟域和虚拟用户所用到的配置文件

//直接在extman中复制过去就可以了

mkdir -pv /etc/postfix/mysql

tar -zxvf extman-1.0.0.tar.gz

cd extman-1.0.0/docs

cp ./mysql_virtual_alias_maps.cf /etc/postfix/mysql/mysql_virtual_alias_maps.cf

cp ./mysql_virtual_limit_maps.cf

/etc/postfix/mysql/mysql_virtual_mailbox_limit_maps.cf

cp ./mysql_virtual_mailbox_maps.cf /etc/postfix/mysql/mysql_virtual_mailbox_maps.cf

cp ./mysql_virtual_domains_maps.cf /etc/postfix/mysql/mysql_virtual_domains_maps.cf

快速复制方法:

cp mysql_virtual* /etc/postfix/mysql

注意,修改复制过去的文件*.cf的内容,数据库的连接用户名和密码!

# vi /etc/hosts //修改为以下内容

127.0.0.1 localhost.localdomain localhost

#::1 localhost6.localdomain6 localhost6

192.168.0.3 mail.188biz.gz mail

安装maildrop-2.2.0

tar -jxvf maildrop-2.2.0.tar.bz2

cd maildrop-2.2.0

yum --disablerepo=\* --enablerepo=\c5-media install pcre-devel

ln -sv /usr/local/authlib/bin/courierauthconfig /usr/bin

ln -sv /usr/local/authlib/include/* /usr/include

./configure --prefix=/usr/local/maildrop --enable-sendmail=/usr/sbin/sendmail

--enable-trusted-users='root vmail' --enable-syslog=1 --enable-maildirquota

--enable-maildrop-uid=1001 --enable-maildrop-gid=1001 --with-trashquota --with-dirsync --enable-authlib

make

make install

cp /usr/local/maildrop/bin/maildrop /usr/bin

cp /usr/local/maildrop/bin/maildrop /usr/local/bin

[root@redhat maildrop-2.2.0]# maildrop -v

maildrop 2.0.4 Copyright 1998-2005 Double Precision, Inc.

GDBM extensions enabled.

Courier Authentication Library extension enabled. //要保证这一行显示

Maildir quota extension enabled.

This program is distributed under the terms of the GNU General Public

License. See COPYING for additional information.

2:配置maildrop的日志文件

------------------------------

vim /etc/maildroprc

logfile "/var/log/maildrop.log"

安装extmail extman

解压复制到目录/var/www/e

tar zxvf extmail-1\[1\]\[1\].1.0.tar.gz

tar zxvf extman-1\[1\]\[1\].0.0.tar.gz

mv extman-1.0.0 /var/www/extsuite/extman

mv extmail-1.1.0 /var/www/extsuite/extmail

配置extman:

cd /var/www/extsuite/extman

vi webman.cf

修改为以下内容:

SYS_SESS_DIR = /var/www/extsuite/extman/tmp

SYS_MAILDIR_BASE = /var/mailbox

SYS_MYSQL_USER = root

SYS_MYSQL_PASS = 188biz

SYS_MYSQL_DB = extmail

SYS_MYSQL_HOST = localhost

SYS_MYSQL_SOCKET = /tmp/mysql.sock

chown -R vmail.vmail extsuite

chown -R vmail.vmail /var/mailbox

导入数据库:

[root@mail docs]# mysql -u root -p < extmail.sql

修改init.sql,将https://www.360docs.net/doc/2c8236983.html, 修改成自己的域名 188biz.gz

文件中也清楚的告诉我们,postmaster@188biz.gz的密码是extmail

root@188biz.gz 的密码是:extmail*123*

导入数据

mysql -u root -p < init.sql

配置extmail

cp webmail.cf.default webmail.cf

vi webmail.cf

SYS_MAILDIR_BASE = /var/mailbox

SYS_MYSQL_USER = root

SYS_MYSQL_PASS = 188biz

SYS_MYSQL_DB = extmail

SYS_MYSQL_HOST = localhost

SYS_MYSQL_SOCKET = /tmp/mysql.sock

===========================================================

测试POP

telnet 192.168.0.3 110

+OK Hello there.

user test@188biz.gz

+OK Password required.

pass test

-ERR Temporary problem, please try again later

出现此错误,请检查日志:

cat /var/log/maillog

Jul 23 12:07:09 mail authdaemond: failed to connect to mysql server (server=localhost.., userid=root): Unknown MySQL server host 'localhost..' (2)

Jul 23 12:07:09 mail authdaemond: authmysql: TEMPFAIL - no more modules will be tried Jul 23 12:07:09 mail pop3d: LOGIN FAILED, user=test@188biz.gz, ip=[::ffff:192.168.0.102] Jul 23 12:07:09 mail pop3d: authentication error: Input/output error

authentication error: Input/output error

这个原因是

原来是authmysqlrc 的配置错误!

中的MSYQLSERVER localhost这一行后面多了空格.

测试maildrop

[root@mail mailbox]# echo test| maildrop -V 10 -d postmaster@188biz.gz

maildrop: authlib: groupid=1001

maildrop: authlib: userid=1001

maildrop: authlib: logname=postmaster@188biz.gz, home=/var/mailbox/188biz.gz/postmaster, mail=/var/mailbox/188biz.gz/postmaster/Maildir/

maildrop: Changing to /var/mailbox/188biz.gz/postmaster

Message start at 0 bytes, envelope sender=postmaster@188biz.gz

Tokenized logfile

Tokenized string: "/var/log/maildrop.log"

Tokenized ;

Tokenized eof

/etc/maildroprc(1): Opening logfile /var/log/maildrop.log

maildrop: Unable to create log file.

出现maildrop: Unable to create log file.

使用以下方法解决:

chown -R vmail.root /var/log

邮件发送的测试:

SMTP

warning: connect to transport private/maildrop: No such file or directory

没有配置好main.cf master.cf

邮件日志回滚:

建议修改/etc/logrotate.d/syslog的回滚配置

如果采用默认的也可以,如果maillog 的文件一个星期不是很大的话。

如果需要,可以重新配置,但必须删除syslog里面的maillog的路径:

/var/log/maillog {

daily

rotate 7

create

sharedscripts

postrotate

/bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true

endscript

}

测试:

logrotate -f /etc/logrotate.conf

有必要的话,可以做一个 crontab

59 23 * * * root /usr/sbin/logrotate -f /etc/logrotate.maillog.conf

看到有新的文件生成即可!

maillog 不是 postfix 生成的日志文件,是syslogd生成的。如果删除了maillog 则需要重新启动syslog就可以了。

===============================================================================

安装clamav-0.95 防病毒

tar -zxvf clamav-0.95.2.tar.gz

cd clamav-0.95.2

groupadd amavis

useradd -g amavis amavis

groupadd clamav

useradd clamav -g clamav

./configure --prefix=/usr/local/clamav --sysconfdir=/etc/clamav --disable-zlib-vcheck --enable-milter --with-dbdir=/usr/local/share/clamav

make

make install

2:新建相关的文件及目录

[root@redhat clamav-0.91.2]# mkdir /var/log/clamav

[root@redhat clamav-0.91.2]# chmod -R 744 /var/log/clamav

[root@redhat clamav-0.91.2]# chown -R amavis:amavis /var/log/clamav

[root@redhat clamav-0.91.2]# chown -R amavis.amavis /usr/local/share/clamav

[root@redhat clamav-0.91.2]# mkdir /var/run/clamav

[root@redhat clamav-0.91.2]# chmod 700 /var/run/clamav

[root@redhat clamav-0.91.2]# chown amavis.amavis /var/run/clamav

//freshclam.conf内容

[root@redhat clamav-0.91.2]# mv /etc/clamav/freshclam.conf

/etc/clamav/freshclam.conf.old

[root@redhat clamav-0.91.2]#vi /etc/clamav/freshclam.conf

DatabaseDirectory /usr/local/share/clamav

UpdateLogFile /var/log/clamav/freshclam.log

LogVerbose yes

LogSyslog yes

LogFacility LOG_MAIL

PidFile /var/run/freshclam.pid

DatabaseOwner amavis

DatabaseMirror https://www.360docs.net/doc/2c8236983.html,

DatabaseMirror https://www.360docs.net/doc/2c8236983.html,

DatabaseMirror https://www.360docs.net/doc/2c8236983.html,

//clamd文件内容

[root@redhat clamav-0.91.2]# mv /etc/clamav/clamd.conf /etc/clamav/clamd.conf.old [root@redhat clamav-0.91.2]# vi /etc/clamav/clamd.conf

LogFile /var/log/clamav/clamd.log

LogSyslog yes

LogFacility LOG_MAIL

LogVerbose yes

PidFile /var/run/clamav/clamd.pid

DatabaseDirectory /usr/local/share/clamav

LocalSocket /var/run/clamav/clamd.socket

StreamMaxLength 20M

User amavis

ScanELF yes

ScanPDF yes

ScanMail yes

PhishingSignatures yes

3:配置库文件及开机自启动

[root@redhat clamav-0.95.2]# cp clamd/clamd /etc/rc.d/init.d/clamd

[root@redhat clamav-0.95.2]# chkconfig --add clamd

[root@redhat clamav-0.95.2]# chkconfig --level 2345 clamd on

[root@redhat clamav-0.95.2]# echo "/usr/local/clamav/lib" >> /etc/ld.so.conf [root@redhat clamav-0.95.2]# ldconfig -v

4:启动服务及添加自动任务

[root@redhat clamav-0.91.2]# vi /etc/rc.d/init.d/clamd

progdir="/usr/local/clamav/sbin" //第19行

[root@redhat clamav-0.91.2]# service clamd start

Starting clamd: [ OK ]

[root@redhat clamav-0.91.2]#

[root@redhat clamav-0.91.2]# crontab -e

37 * * * * /usr/local/clamav/bin/freshclam //增加系统启动任务

[root@redhat clamav-0.91.2]#/usr/local/clamav/bin/freshclam

ClamAV update process started at Thu Dec 6 04:09:24 2007

WARNING: Your ClamAV installation is OUTDATED!

WARNING: Local version: 0.91.2 Recommended version: 0.92

DON'T PANIC! Read [url]https://www.360docs.net/doc/2c8236983.html,/support/faq[/url]

Downloading main-45.cdiff [100%]

手动更新

/usr/local/clamav/bin/freshclam

安装:Mail-SpamAssassin-3.2.5 反垃圾邮件工具

tar -zxvf Mail-SpamAssassin-3.2.5.tar.gz

amavisd-new-2.6.4 防病毒及防垃圾邮件相关

tar -zxvf amavisd-new-2.6.4.tar.gz

cd amavisd-new-2.6.4

mkdir -p /var/amavis /var/amavis/tmp /var/amavis/var /var/amavis/db

chown -R amavis:amavis /var/amavis

chmod -R 750 /var/amavis

cp amavisd /usr/local/sbin/

chown root /usr/local/sbin/amavisd

chmod 755 /usr/local/sbin/amavisd

cp amavisd.conf /etc/

chown root /etc/amavisd.conf

chmod 644 /etc/amavisd.conf

mkdir /var/virusmails

chown amavis:amavis /var/virusmails

chmod 750 /var/virusmails

执行完后别忘记检查一下是否都按我们的意愿工作,如/usr/local/sbin目录是否有文件amavisd。

2:配置amavisd.conf文件

//因该文件内容较多,这里只列出比较重要的选项,完整的文件将会在附件中给出

[root@redhat tmp]# vi /etc/amavisd.conf

$max_servers=8;

$daemon_user = 'amavis';

$daemon_group = 'amavis';

$mydomain = 'https://www.360docs.net/doc/2c8236983.html,';

$db_home = "$MYHOME/db";

$inet_socket_port = 10024;

$sa_tag_level_deflt = -100;

$sa_tag2_level_deflt = 6.3;

$sa_kill_level_deflt = $sa_tag2_level_deflt;

$virus_admin = "virusalert@$mydomain";

$sa_spam_subject_tag = '***SPAM*** ';

$notify_method = $forward_method;

$forward_method = 'smtp:127.0.0.1:10025';

$final_virus_destiny = D_DISCARD;

$final_banned_destiny = D_DISCARD;

$final_spam_destiny = D_PASS;

$virus_admin = "postmaster\@$mydomain"; # notifications recip.

$mailfrom_notify_admin = "postmaster\@$mydomain"; # notifications sender

$mailfrom_notify_recip = "postmaster\@$mydomain"; # notifications sender

$mailfrom_notify_spamadmin = "postmaster\@$mydomain"; # notifications sender $mailfrom_to_quarantine = ''; # null return path; uses original sender if undef

['ClamAV-clamd',

&ask_daemon, ["CONTSCAN {}n", "/var/run/clamav/clamd.socket"],

qr/bOK$/, qr/bFOUND$/,

qr/^.*?: (?!Infected Archive)(.*) FOUND$/ ],

3:测试启动

[root@redhat amavisd-new-2.5.2]# /usr/local/sbin/amavisd debug

//如果出现以下的错误,则需重新编译64(Convert-UUlib)

Problem in Amavis::Unpackers code: Can't locate Convert/UUlib.pm in @INC

4:测试启动spamassassin

//更改/etc/mail/spammassassin/local.cf中的值为下面的参数

required_hits 10.0

rewrite_subject 1

required_score 5.0

rewrite_header Subject *****SPAM*****

report_safe 1

use_bayes 1

bayes_auto_learn 1

skip_rbl_checks 1

use_razor2 0

use_pyzor 0

ok_locales all

[root@linux ~]# spamassassin -d --lint

[root@linux ~]# /usr/bin/spamd -d

[26002] warn: server socket setup failed, retry 1: spamd: could not create INET socket on [26002] warn: server socket setup failed, retry 2: spamd: could not create INET socket on [26002] error: spamd: could not create INET socket on 127.0.0.1:783: Address already in use

spamd: could not create INET socket on 127.0.0.1:783: Address already in use

[root@linux ~]# echo "/usr/bin/spamd -d" >> /etc/rc.local

[root@linux ~]#

5:启动amavis并测试postfix ,正常情况下应出现下面的提示

[root@redhat amavisd-new-2.5.2]# /usr/local/sbin/amavisd

[root@redhat amavisd-new-2.5.2]# postfix start

postfix/postfix-script: starting the Postfix mail system

[root@redhat amavisd-new-2.5.2]# telnet localhost 10024

Trying 127.0.0.1...

Connected to localhost.localdomain (127.0.0.1).

Escape character is '^]'.

220 [127.0.0.1] ESMTP amavisd-new service ready

EHLO https://www.360docs.net/doc/2c8236983.html,

250-[127.0.0.1]

250-VRFY

250-PIPELINING

250-SIZE

相关主题
相关文档
最新文档