RedHat AS40 轻松搭建Postfix 邮件服务器系统.docx
《RedHat AS40 轻松搭建Postfix 邮件服务器系统.docx》由会员分享,可在线阅读,更多相关《RedHat AS40 轻松搭建Postfix 邮件服务器系统.docx(42页珍藏版)》请在冰点文库上搜索。
![RedHat AS40 轻松搭建Postfix 邮件服务器系统.docx](https://file1.bingdoc.com/fileroot1/2023-5/17/17388999-2e71-4c2e-99dc-52b91defdf53/17388999-2e71-4c2e-99dc-52b91defdf531.gif)
RedHatAS40轻松搭建Postfix邮件服务器系统
RedHatAS4.0轻松搭建Postfix邮件服务器系统
RedHatAS4.0轻松搭建Postfix邮件服务器系统
作者:
liheng
Email:
liheng_2006@liheng@
序言:
一直都非常想自己做一个邮件服务器玩玩,有这个想法很久了,但却一直都没有做,总结的原因是:
太忙了,没时间。
嘿嘿~~~~究竟忙的什么,我就不透露了。
上个月,终于痛下决心,一定要弄出个邮件服务器出来玩玩不可,也正因为此,才有了本文的诞生。
之前用了一个月时间看了postfix的经典之作---《postfix权威指南》,首先要大致摸个底嘛。
但看完一遍以后,总体上的感觉是,书是写得很好,但自己就是有很多不明白,看不懂的地方。
看来还是得亲自做出来,熟悉一下大致的框架才行,这样看的话,有点盲人摸象的感觉。
既然已经决定,那就马上行动吧,Let’sgo!
本文的配置参照了互联网上不少前辈的文章,在这里我要向他们致敬,没有他们无私的奉献,我想依靠我一个人无法做得出来这么庞大的邮件系统。
我在配置邮件服务器的过程中,遇到了不少问题,smtp验证我弄了一个星期,chdirMaildirfailed这个问题弄了半个月。
多得了互联网上不少热心朋友的指点,才使得最终我的邮件服务器得以成功,在这里要非常谢谢他们。
安装postfix邮件服务器所需的软件列表:
1、 RedHatas4.0
RedHat高级服务器操作系统
2、Postfix
这一个是自然少不了的,邮件服务器系统的smtp服务器,在邮件服务器系统中充当MTA角色。
软件版本:
postfix-2.4.5
下载地址:
http:
//www.postfix.org/download.html
3、mysql
最优秀的开源数据库之一,用于存储虚拟域、虚拟账户信息。
使用的版本:
mysql-5.0.45
下载地址:
4、apache
最优秀的web服务器软件之一,用于extman的后台管理,extmail的web邮件收发。
软件版本:
httpd-2.2.4
下载地址:
http:
//www.apache.org
5、php
Extman&extmail需要使用php.作用版本:
php-5.2.3
下载地址:
6、cyrus-sasl
用于实现身份验证的smtp服务器,使用版本:
cyrus-sasl-2.1.22
下载地址:
7、courier-authlib
实现带验证的pop3服务器,使用版本:
courier-authlib-0.58
下载地址:
8、courier-imap
用于实现pop3、imap收邮件功能,使用版本:
courier-imap-4.1.0
下载地址:
...6&Resourceid=77
9、openssl
提供安全的邮件服务器连接,使用版本:
openssl-0.9.8e
下载地址:
http:
//www.openssl.org/source
10、extman
用于邮件服务器的后台管理,使用版本:
extman-0[1].2.2
下载地址:
http:
//www.extmail.org
11、extmail
用于实现webmail.使用版本:
extmail-1[1].0.2
下载地址:
http:
//www.extmail.org
12、DBD-Mysql
用于解决依赖关系,extmail将会用到,使用版本:
DBD-Mysql-3.0002_4
下载地址:
http:
//search.cpan.org
13、Unix-Syslog
用于解决依赖关系,extmail将会用到,使用版本:
Unix-Syslog-0.100
下载地址:
http:
//search.cpan.org
14、BerkeleyDB
使用版本:
BerkeleyDB-4.5.20
下载地址:
...keley-db/index.html
15、pcre
安装maildrop时需要,使用版本:
pcre-7.4
下载地址:
16、maildrop
用来代替postfix自带的MDA,是一个带有过滤功能的MDA,使用版本:
maildrop-2.02
下载地址:
邮件服务器系统的安装
本文约定:
默认情况下,本文中的所有软件的压缩安装文件都放在/root目录下,除非特别说明的情况下。
友情提示:
本文中用红色字体标的“注意”部分与文档后面的FAQ部分,仅作参考之用,如果你在安装的时候遇到类似问题,可以提供一个解决问题的思路之用。
禁用selinux
[root@testroot]#vi/etc/selinux/conifg
#ThisfilecontrolsthestateofSELinuxonthesystem.
#SELINUX=cantakeoneofthesethreevalues:
# enforcing-SELinuxsecuritypolicyisenforced.
# permissive-SELinuxprintswarningsinsteadofenforcing.
# disabled-SELinuxisfullydisabled.
将SELINUX=enforcing
改成
SELINUX=disabled
#SELINUXTYPE=typeofpolicyinuse.Possiblevaluesare:
# targeted-Onlytargetednetworkdaemonsareprotected.
# strict-FullSELinuxprotection.
SELINUXTYPE=targeted
Selinux是linux系统中一个强制性的安全机制,但也带来了不少麻烦,为了避免不必要的麻烦,还是先关了吧。
我之前在Fedoracora5上安装邮件服务器时就因为没有关掉selinux,而苦恼了一段时间。
1、 安装mysql
添加虚帐户mysql并同时产生一个mysql组。
注:
如果系统中已有就不必添加了。
[root@testroot]#groupadd mysql
[root@testroot]#useradd-gmysqlmysql
解压缩mysql安装文件
[root@testroot]#cpmysql-5.0.45-linux-i686-glibc23.tar.gz/usr/local
[root@testroot]#cd/usr/local
[root@testlocal]#tarxvzfmysql-5.0.45-linux-i686-glibc23.tar.gz
[root@testlocal]#ln-smysql-5.0.45-linux-i686-glibc23mysql
[root@testlocal]#mv/etc/f/etc/f.bak
[root@testlocal]#cpmysql/support-files/my-f/etc/f
初始化mysql数据库
[root@testlocal]#cdmysql
[root@testmysql]#./script/mysql_install_db —user=mysql&
修改目录所有权限为mysql所有
[root@testmysql]#chown-Rroot.
[root@testmysql]#chown-Rmysql:
mysqldata
[root@testmysql]#chgrp-Rmysql.
启动测试mysql
[root@testlocal]#/usr/local/mysql/bin/safe_mysqld—user=mysql&
Startingmysqlddaemonwithdatabasesfrom/usr/local/mysql/data
查看mysql是否已经正式启动
[root@testlocal]#netstat–tlunp|grepmysql
/////******************************注意***************************
这一步可以省略,可以先查看在/tmp目录下是否存在mysql.sock这个文件,如果没有的话,就需要链接,有的话,就不必啦。
[root@testlocal]#ln-s/var/lib/mysql/mysql.sock/tmp/
注:
将/var/lib/mysql/mysql.sock链接到/tmp目录下,并保持名称不变,如果不这样做的话,有时候可能mysql启动时会报错,如ERROR200:
Can’tconnecttolocalMYSQLserverthrouhtsocket/tmp/mysql.sock.
******************************************************************\\\\\\\\\
复制一个编译目录的脚本,以使mysql每次启动时都能自动运行
[root@testmysql]#cpsupport-files/mysql.server/etc/rc.d/init.d/mysqld
[root@testmysql]#chmod755/etc/init.d/mysqld
[root@testmywql]#chkconfig—addmysqld
[root@testmysql]#chkconfig—level35mysqldon
[root@testlocal]#mkdir/usr/local/mysql/lib/mysql
[root@testlocal]#mkdir/usr/local/mysql/include/mysql
[root@testlocal]#chownroot.mysql/usr/local/mysql/lib/mysql
[root@testlocal]#chwonroot.mysql/usr/local/mysql/include/mysql
[root@testlocal]#ln–s/usr/local/mysql/lib/*/usr/local/mysql/lib/mysql
[root@testlocal]#ln–s/usr/local/mysql/include/*/usr/local/mysql/include/mysql
[root@testlocal]#echo“/usr/local/mysql/lib/mysql”>>/etc/ld.so.conf
[root@testlocal]#ldconfig
2、安装openssl
[root@testroot]#tarzxvfopenssl-0.9.8e.tar.gz
[root@testroot]#cdopenssl-0.9.8e
[root@testopenssl-0.9.8e]#./configsharedzlib
[root@testopenssl-0.9.8e]#make
[root@testopenssl-0.9.8e]#maketest
[root@testopenssl-0.9.8e]#makeinstall
[root@testopenssl-0.9.8e]#mv/usr/bin/openssl/usr/bin/openssl.OFF
[root@testopenssl-0.9.8e]#mv/usr/include/openssl/usr/include/openssl.OFF
[root@testopenssl-0.9.8e]#rm-rf/usr/lib/libssl.so
[root@testopenssl-0.9.8e]#ln-s/usr/local/ssl/bin/openssl/usr/bin/openssl
[root@testopenssl-0.9.8e]#ln-s/usr/local/ssl/include/openssl/usr/include/openssl
[root@testopenssl-0.9.8e]#ln-sv/usr/local/ssl/lib/libssl.so.0.9.8 /usr/lib/libssl.so
配置库文件搜索路径
[root@testopenssl-0.9.8e]#echo"/usr/local/ssl/lib">>/etc/ld.so.conf
[root@testopenssl-0.9.8e]#ldconfig
检查是否安装openssl
[root@testopenssl-0.9.8e]#opensslversion
OpenSSL0.9.8e23Feb2007
2、 安装cyrus-sasl
[root@testopenssl-0.9.8e]#cd
[root@testroot]#tarxzvfcyrus-sasl-2.1.22.tar.gz
[root@testroot]#cdcyrus-sasl-2.1.22
[root@testcyrus-sasl-2.1.22]#./configure--prefix=/usr/local/sasl2 --disable-gssapi--disable-anon--disable-sample--disable-digest
--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/courier-authlib/var/spool/authdaemon/socket
[root@testcyrus-sasl-2.1.22]#make
[root@testcyrus-sasl-2.1.22]#makeinstall
关闭原有的sasl
[root@testcyrus-sasl-2.1.22]#mv/usr/lib/libsasl2.a /usr/lib/libsasl2.a.OFF
[root@testcyrus-sasl-2.1.22]#mv/usr/lib/libsasl2.la /usr/lib/libsasl2.la.OFF
[root@testcyrus-sasl-2.1.22]#mv/usr/lib/libsasl2.so.2.0.19 /usr/lib/libsasl2.so.2.0.19.OFF
[root@testcyrus-sasl-2.1.22]#mv/usr/lib/sasl2 /usr/lib/sasl2.OFF
[root@testcyrus-sasl-2.1.22]#rm-rf/usr/lib/libsasl2.so
[root@testcyrus-sasl-2.1.22]#rm–rf/usr/lib/libsasl2.so.2
[root@testcyrus-sasl-2.1.22]#ln-s/usr/local/sasl2/lib/* /usr/lib
postfix2.3以后的版本会分别在/usr/local/lib和/usr/local/include中搜索sasl库文件及头文件,故还须将其链接至此目录中:
[root@testcyrus-sasl-2.1.22]#ln-sv/usr/local/sasl2/lib/* /usr/local/lib
[root@testcyrus-sasl-2.1.22]#ln-sv/usr/local/sasl2/include/sasl/* /usr/local/include
创建运行时需要的目录并调试启动
[root@testcyrus-sasl-2.1.22]#mkdir-pv/var/state/saslauthd
[root@testcyrus-sasl-2.1.22]#/usr/local/sasl2/sbin/saslauthd -a shadow pam -d
使用Ctrl+C中断
启动并测试
[root@testcyrus-sasl-2.1.22]#/usr/local/sasl2/sbin/saslauthd-ashadowpam
配置库文件搜索路径
[root@testcyrus-sasl-2.1.22]#echo"/usr/local/sasl2/lib">>/etc/ld.so.conf
[root@testcyrus-sasl-2.1.22]#echo"/usr/local/sasl2/lib/sasl2">>/etc/ld.so.conf
[root@testcyrus-sasl-2.1.22]#ldconfig
开机自动启动
[root@testcyrus-sasl-2.1.22]#echo"/usr/local/sasl2/sbin/saslauthd-ashadowpam">>/etc/rc.local
4、安装Berkeley-DB
[root@testroot]#tarzxvfdb-4.5.20.tar.gz
[root@testroot]#cddb-4.5.20/build_unix
[root@testbuild_unix]#../dist/configure—prefix=/usr/local/BerkeleyDB
[root@testbuild_unix]#make
[root@testbuild_unix]#makeinstall
修改相应的头文件指向
[root@testbuild_unix]#mv /usr/inculde/db4 /usr/inculde/db4.OFF
[root@testbuild_unix]#rm -rf/usr/inculde/db_cxx.h
[root@testbuild_unix]#rm -rf/usr/inculde/db.h
[root@testbuild_unix]#rm -rf/usr/inculde/db_185.h
[root@testbuild_unix]#ln-s/usr/local/BerkeleyDB/include /usr/include/db4
[root@testbuild_unix]#ln-s/usr/local/BerkeleyDB/include/db.h /usr/include/db.h
[root@testbuild_unix]#ln–s/usr/local/BerkeleyDB/include/db_cxx.h /usr/include/db_cxx.h
配置库文件搜索路径
[root@testbuild_unix]#echo"/usr/local/BerkeleyDB/lib">>/etc/ld.so.conf
[root@testbuild_unix]#ldconfig
5、安装httpd-2.2.4
[root@testroot]#tarjxvfhttpd-2.2.4.tar.bz2
[root@testroot]#cdhttpd-2.2.4
[root@testhttpd-2.2.4]#./configure
--prefix=/usr/local/apache--enable-so--enable-ssl
--with-ssl=/usr/local/ssl--enable-track-vars--enable-rewrite--with-zlib
--enable-mods-shared=most --enable-suexec —with-suexec-caller=daemon
[root@testhttpd-2.2.4]#make
[root@testhttpd-2.2.4]#makeinstall
[root@testhttpd-2.2.4]#echo"/usr/local/apache/bin/apachectlstart">>/etc/rc.local(系统启动时服务自动启动)
6、安装php-5.2.3
[root@testroot]#tar-zvxfphp-5.2.3.tar.gz
[root@testroot]#mkdir-p/usr/local/php
[root@testroot]#cdphp-5.2.3
[root@testphp-5.2.3]#./configure—prefix=/usr/local/php