suse 邮件服务器,mail服务器一步到位之安装篇

1、AMP---apache(web服务) 、mysql(数据库)、php(非必需) 的简称

2、postfix--mta邮件系统核心

3、courier-authlib--一个为courier-imap,maildrop,sasl2提供用户信息的后台进程序

4、courier-imap--提供pop3,pop3s,imap,imaps服务的程序

5、amavisd-new--提供内容过滤

6、clamav-- 著名的杀毒软件

7、extmail--一个著名的webmail程序

8、extman--与extmail集成的后台管理程序

9、slockd--一个基于smtp阶段的反垃圾邮件程序

10、vhmgr--由本文作者编写,用于管理apache,ftp,mysql的虚拟主机管理程序。

系统安装

1、系统安装包

基本库、开发库、开发工具

2、配置yum,在本文中使用的是网通线路,所以选择了作为安装镜像。

[root@localhost ~]# cd /etc/yum.repos.d/

[root@localhost yum.repos.d]# wget CentOS-Base.repo.ta139

[root@localhost yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.bak

[root@localhost yum.repos.d]# mv CentOS-Base.repo.ta139 CentOS-Base.repo

与配置调试

第一节安装AMP

apache(web服务)、mysql(数据库)、php(非必需)

[root@localhost ~]# yum -y install httpd httpd-devel mysql mysql-devel mysql-server php php-xml php-cli php-pdo php-mbstring php-mcrypt php-gd php-common php-devel php-mysql

修改启动配置并启动

[root@localhost ~]# chkconfig --level 345mysqld on

[root@localhost ~]# chkconfig --level 345httpd on

[root@localhost ~]# service mysqld start

[root@localhost ~]# service httpd start

第二节安装phpmyadmin

注意:可以选择自己需要的版本

[root@localhost ~]# wget 2.11.9-all-languages-utf-8-only.tar.bz2

[root@localhost ~]# tar xjf phpMyAdmin-2.11.9-all-languages-utf-8-only.tar.bz2

[root@localhost ~]# mv phpMyAdmin-2.11.9-all-languages-utf-8-only /var/www/html/phpmyadmin

[root@localhost phpmyadmin]# cp config.sample.inc.php config.inc.php

编辑config.inc.php改为下面,字符串是任意的。

$cfg['blowfish_secret'] = 'skssiwksksie'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

进入phpmyadmin请马上修改mysql root用户的密码。

第三节导入extman后台数据库

将extmail/extman/slockd上传到服务器,可以使用ftp/winscp上传

[root@localhost ~]# tar zxf extman-0.2.5b1.tar.gz

[root@localhost ~]# cd extman-0.2.5b1/docs/

[root@localhost docs]# mysql -uroot -p

Enter password:

[root@localhost docs]# mysql -uroot -p

Enter password:

如何使用了phpmyadmin改了root密码,记得输入密码,如果密码为空,请按回车。

第四节采用RPM源码包安装

下面我们将采用rpm的方式安装软件/usr/src/redhat/SPEC spec文件夹,通常是rpm文件夹/usr/src/redhat/RPMS是生成rpm的文件,下面还有i368,i486等子文件夹,一般我们用i386架构/usr/src/redhat/SOURCE源文件文件夹为了安装时切换目录的方便,我们将目录存放到一个shell变量里。

[root@localhost ~]# export RPMS=/usr/src/redhat/RPMS

[root@localhost ~]# export SOURCE=/usr/src/redhat/SOURCES

[root@localhost ~]# export SPEC=/usr/src/redhat/SPECS

在下面安装过程中,大家要记住cd $RPMS与cd /usr/src/redhat/RPMS的目的是一样的,只是shell变量的替换。

第五节安装authlib

一个为courier-imap,maildrop,sasl2提供用户信息的后台进程序

安装依懒的包

[root@localhost ~]# yum -y install postgresql-devel expect libtool-ltdl-devel

[root@localhost ~]# wget

[root@localhost ~]# tar xjf courier-authlib-0.61.0.tar.bz2

[root@localhost ~]# cd courier-authlib-0.61.0

[root@localhost courier-authlib-0.61.0]# cp courier-authlib.spec $SPEC

[root@localhost courier-authlib-0.61.0]# cd ..

[root@localhost ~]# cp courier-authlib-0.61.0.tar.bz2 $SOURCE

[root@localhost ~]# cd $SPEC

[root@localhost SPECS]# rpmbuild -bb courier-authlib.spec(创建rpm文件)

安装生成的rpm

[root@localhost SPECS]# cd $RPMS/i386

[root@localhost i386]# rpm -ivh courier-authlib-0.61.0-1.i386.rpm

[root@localhost i386]# rpm -ivh courier-authlib-devel-0.61.0-1.i386.rpm

[root@localhost i386]# rpm -ivh courier-authlib-mysql-0.61.0-1.i386.rpm

配置authlibdaemon

[root@localhost i386]# cd /etc/authlib/

[root@localhost authlib]# mv authdaemonrc authdaemonrc.bak

[root@localhost authlib]# vim authdaemonrc

输入下面的内容:

authmodulelist="authmysql"

authmodulelistorig="authmysql"

daemons=10

authdaemonvar=/var/spool/authdaemon

DEBUG_LOGIN=2

DEFAULTOPTIONS="wbnodsn=1"

LOGGEROPTS=""

D、配置authmysqlrc

[root@localhost authlib]# mv authmysqlrc authmysqlrc.bak

[root@localhost authlib]# vim authmysqlrc

输入下面的内容:

MYSQL_SERVERlocalhost

MYSQL_USERNAMEextmail

MYSQL_PASSWORDextmail

MYSQL_PORT0

MYSQL_SOCKET/var/lib/mysql/mysql.sock

MYSQL_OPT0

MYSQL_DATABASEextmail

MYSQL_SELECT_CLAUSESELECT username,password,"",uidnumber,gidnumber,\

CONCAT('/home/data/domains/',homedir),\

CONCAT('/home/data/domains/',maildir),\

quota,\

name\

FROM mailbox\

WHERE username = '$(local_part)@$(domain)'

启动authlib

[root@localhost ~]# service courier-authlib start

Starting Courier authentication services: authdaemond

[root@localhost ~]# chmod 777 /var/spool/authdaemon/

第六节安装courier-imap

-提供pop3,pop3s,imap,imaps服务的程序【MUA】

由于courier-imap不能用root身份生成rpm那么我们新建一个普通用户,并创建一个rpm环境

[root@localhost ~]# useradd yiyou

软件包依懒需要安装openldap-server,rpm创建完成后可以删除

[root@localhost ~]# yum -y install openldap-servers

[root@localhost ~]# su - yiyou

[yiyou@localhost ~]$ mkdir -p rpm/{BUILD,RPMS,SOURCES,SPECS,SRPMS}

[yiyou@localhost ~]$ vim~/.rpmmacros

输入内容:

%_topdir /home/yiyou/rpm

[yiyou@localhost ~]$ wget 4.4.1.tar.bz2

[yiyou@localhost ~]$ cp courier-imap-4.4.1.tar.bz2 rpm/SOURCES/

[yiyou@localhost ~]$ tar xjf courier-imap-4.4.1.tar.bz2

[yiyou@localhost ~]$ cd courier-imap-4.4.1

[yiyou@localhost courier-imap-4.4.1]$ cp courier-imap.spec ../rpm/SPECS/

[yiyou@localhost courier-imap-4.4.1]$ cd ../rpm/SPECS/

编辑courier-imap.spec将下面的内容:

%if %suse_version

BuildPreReq: rpm >= 3.0.5 /usr/bin/sed openldap2 openldap2-devel %([ %{suse_version} -gt 819 ] && echo /usr/include/fam.h)

%else

BuildPreReq: rpm >= 4.0.2 sed /usr/include/fam.h openldap-devel openldap-servers

%endif

改为:

%if %suse_version

BuildPreReq: rpm >= 3.0.5 /usr/bin/sed openldap2 openldap2-devel

%else

BuildPreReq: rpm >= 4.0.2 sed openldap-devel openldap-servers

%endif

创建rpm

[yiyou@localhost SPECS]$ rpmbuild -bb courier-imap.spec

完成rpm后,输入exit退出当前用户。

[root@localhost ~]# rpm -ivh /home/yiyou/rpm/RPMS/i386/courier-imap-4.4.1-1.i386.rpm

[root@localhost ~]# service courier-imap start

第七节安装cyrus-sasl

Simple Authentication Security Layer

安装SRPM

[root@localhost ~]# wget ftp://194.199.20.114/linux/fedora/updates/8/SRPMS/cyrus-sasl-2.1.22-8.fc8.src.rpm

[root@localhost ~]# rpm -ivh cyrus-sasl-2.1.22-8.fc8.src.rpm

[root@localhost ~]# cd $SPEC

编辑cyrus-sasl.spec将下面:

# Bundling copy of Berkeley DB, for sasldb support.

topdir=`pwd`

pushd db-%{db_version}/build_unix

../dist/configure \

--with-mutex=UNIX/fcntl --disable-shared --enable-static --with-pic \

--with-uniquename=_cyrus_sasl_sasldb_rh \

--prefix=${topdir}/db-instroot \

--includedir=${topdir}/db-instroot/include \

--libdir=${topdir}/db-instroot/lib

改为:

# Bundling copy of Berkeley DB, for sasldb support.

topdir=`pwd`

pushd db-%{db_version}/build_unix

../dist/configure \

--with-mutex=UNIX/fcntl --disable-shared --enable-static --with-pic \

--with-uniquename=_cyrus_sasl_sasldb_rh \

--prefix=${topdir}/db-instroot \

--includedir=${topdir}/db-instroot/include \

--libdir=${topdir}/db-instroot/lib \

--with-authdaemond=/var/spool/authdaemon

生成rpm

[root@localhost SPECS]# rpmbuild -bb cyrus-sasl.spec

[root@localhost RPMS]# cd $RPMS/i386

[root@localhost i386]# rpm -e --nodeps cyrus-sasl-devel cyrus-sasl-plain cyrus-sasl cyrus-sasl-lib(如果这些包存在)

[root@localhost i386]# rpm -ihv cyrus-sasl-lib-2.1.22-8.i386.rpm

[root@localhost i386]# rpm -ihv cyrus-sasl-2.1.22-8.i386.rpm

[root@localhost i386]# rpm -ihv cyrus-sasl-plain-2.1.22-8.i386.rpm

配置sasl2

创建/usr/lib/sasl2/smtpd.conf文件,输入下面的内容:

pwcheck_method:authdaemond

log_level:3

mech_list:PLAIN LOGIN

authdaemond_path:/var/spool/authdaemon/socket

第八节安装postfix

mta邮件系统核心

下载软件包

[root@localhost i386]# cd

[root@localhost ~]# wget 2.5.4-2.src.rpm

[root@localhost ~]# rpm -ivh postfix-2.5.4-2.src.rpm

[root@localhost ~]# cd $SPEC

编辑postfix.spec修改下面的选项

%define distribution rhel-5.0

%define with_mysql_redhat 1

%define with_sasl2

%define with_vda1

创建rpm

[root@localhost SPECS]# rpmbuild -bb postfix.spec

[root@localhost RPMS]# cd $RPMS/i386

[root@localhost i386]# rpm -ivh postfix-2.5.4-2.rhel4.i386.rpm

切换mta

[root@localhost i386]# alternatives --config mta(选择2,postfix)

[root@localhost i386]# rpm -e sendmail

[root@localhost i386]# cd /usr/sbin/

[root@localhost sbin]# mv sendmail sendmail.bak

[root@localhost sbin]# newaliases

[root@localhost sbin]# ln -s sendmail.postfix sendmail

配置postfix

[root@localhost ~]# cd /etc/postfix/

[root@localhost postfix]# mv main.cf main.cf.bak

[root@localhost postfix]# vim main.cf

输入下面的内容:

queue_directory = /var/spool/postfix

command_directory = /usr/sbin

daemon_directory = /usr/libexec/postfix

data_directory = /var/lib/postfix

mail_owner = postfix

unknown_local_recipient_reject_code = 550

debug_peer_level = 2

debugger_command =

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

ddd $daemon_directory/$process_name $process_id & sleep 5

sendmail_path = /usr/sbin/sendmail.postfix

newaliases_path = /usr/bin/newaliases.postfix

mailq_path = /usr/bin/mailq.postfix

setgid_group = postdrop

html_directory = /usr/share/doc/postfix-2.5.2-documentation/html

manpage_directory = /usr/share/man

sample_directory = /etc/postfix

readme_directory = /usr/share/doc/postfix-2.5.2-documentation/readme

alias_database = hash:/etc/postfix/aliases

alias_maps = hash:/etc/postfix/aliases

myhostname = mail.yiyou.org

mydomain = yiyou.org

mydestination = $myhostname

smtpd_banner = yiyou.org ESMTP Mail System

message_size_limit = 14680064

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

virtual_mailbox_base = /home/data/domains

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

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

virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql_virtual_limit_maps.cf

virtual_transport = maildrop:

maildrop_destination_recipient_limit = 1

#sasl

smtpd_sasl_auth_enable = yes

smtpd_sasl2_auth_enable = yes

smtpd_sasl_security_options = noanonymous

broken_sasl_auth_clients = yes

smtpd_recipient_restrictions =

permit_mynetworks,

permit_sasl_authenticated,

reject_unauth_destination,

reject_unauth_pipelining,

reject_invalid_hostname

复制extman/docs目录的cf文件到/etc/postfix

[root@localhost postfix]# cp /root/extman-0.2.5b1/docs/mysql_virtual_* .

因为配置文件的用户、密码与数据库时一样,所以不用修改。

[root@localhost postfix]# service postfix start

第九节安装maildrop

MDA邮件系统核心

下载生成RPM

[root@localhost postfix]# cd

[root@localhost ~]# wget 2.0.4.tar.bz2

[root@localhost ~]# cp maildrop-2.0.4.tar.bz2 $SOURCE

[root@localhost ~]# tar xjf maildrop-2.0.4.tar.bz2

[root@localhost ~]# cd maildrop-2.0.4

[root@localhost maildrop-2.0.4]# cp maildrop.spec $SPEC

[root@localhost maildrop-2.0.4]# cd $SPEC

编辑maildrop.spec把下面:

BuildRequires: /usr/include/fam.h gdbm-devel pcre-devel

改为:

BuildRequires:gdbm-devel pcre-devel

把下面:

%configure --with-devel --enable-userdb --enable-maildirquota\

--enable-syslog=1 --enable-trusted-users='root mail daemon postmaster qmaild mmdf' \

--enable-restrict-trusted=0 \

--enable-sendmail=/usr/sbin/sendmail

改为:

%configure --with-devel --enable-userdb --enable-maildirquota \

--enable-syslog=1 --enable-trusted-users='root mail daemon postmaster qmaild mmdf' \

--enable-restrict-trusted=0 --enable-sendmail=/usr/sbin/sendmail \

--enable-authlib

创建安装maildrop rpm

[root@localhost SPECS]# yum -y install pcre-devel

[root@localhost SPECS]# rpmbuild -bb maildrop.spec

[root@localhost SPECS]# cd $RPMS/i386

[root@localhost i386]# rpm -ivh maildrop-2.0.4-1.i386.rpm

添加虚似用户及创建目录

[root@localhost i386]# cd

[root@localhost ~]# groupadd -g 1000 vgroup

[root@localhost ~]# useradd -g 1000 -u 1000 -s /sbin/nologin -d /dev/null vuser

编辑/etc/postfix/master.cf,加入下面的内容:

maildrop unix -nn--pipe

flags=DRhu user=vuser argv=/usr/bin/maildrop -d ${user}@${nexthop} ${recipient} ${user} ${extension} ${nexthop}

创建邮件存储目录

[root@localhost ~]# mkdir -p /home/data/domains/extmail.org/postmaster

[root@localhost ~]# maildirmake /home/data/domains/extmail.org/postmaster/Maildir

[root@localhost ~]# chown -R vuser:vgroup /home/data/domains/

测试maildrop

[root@localhost ~]# echo "test" | maildrop -V 10 -d postmaster@extmail.org

maildrop: authlib: groupid=1000

maildrop: authlib: userid=1000

maildrop: authlib: logname=postmaster@extmail.org, home=/home/data/domains/extmail.org/postmaster, mail=/home/data/domains/extmail.org/postmaster/Maildir/

maildrop: Changing to /home/data/domains/extmail.org/postmaster

Message start at 0 bytes, envelope sender=postmaster@extmail.org

maildrop: Attempting .mailfilter

maildrop: Delivery complete.

出现上以信息说明authlib,maildrop工作正常

postconf –n测试配置内容是否有问题?

测试pop3

[root@localhost ~]# telnet localhost 110

Trying 127.0.0.1...

Connected to localhost.localdomain (127.0.0.1).

Escape character is '^]'.

+OK Hello there.

user postmaster@extmail.org

+OK Password required.

pass extmail

+OK logged in.

list

+OK POP3 clients that break here, they violate STD53.

1 6

.

retr 1

+OK 6 octets follow.

test

.

quit

+OK Bye-bye.

Connection closed by foreign host.

测试postfix

[root@localhost ~]# perl -MMIME::Base64 -e 'print encode_base64("postmaster\@extmail.org");'

cG9zdG1hc3RlckBleHRtYWlsLm9yZw==

[root@localhost ~]# perl -MMIME::Base64 -e 'print encode_base64("extmail");'

ZXh0bWFpbA==

[root@localhost ~]# service postfix restart(重启一下)

[root@localhost ~]# telnet localhost 25

Trying 127.0.0.1...

Connected to localhost.localdomain (127.0.0.1).

Escape character is '^]'.

220 yiyou.org ESMTP Mail System

ehlo test.com

250-mail.yiyou.org

250-PIPELINING

250-SIZE 14680064

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

235 2.7.0 Authentication successful

quit

221 2.0.0 Bye

Connection closed by foreign host

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值