CentOS6.5上简易搭建Postfix、Dovecot、Sasl、OPenwebmail局域网邮件服务器以及DNS服务器

本教程详细介绍了如何在CentOS6.5环境下搭建邮局服务器,包括停用Sendmail、安装Apache、设置DNS服务器、配置Postfix、Dovecot、Saslauthd以及Openwebmail。通过这些步骤,您可以创建一个用于局域网的邮件服务,并使用Openwebmail进行访问。确保DNS设置正确,以便邮件服务和其他功能正常运行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

环境:VMware11中CentOS6.5 64位 IP地址为192.168.45.128  子网掩码:255.255.255.0,网卡为NAT模式

创建一个普通用户(也就是openwebmail登录用户)

useradd abc

passwd abc

输入两次密码


安装之前检查是否装有Sendmail

Sendmail是默认安装的,停用或者卸载掉。(6.0之后postfix为default) 

# chkconfig sendmail off //chkconfig命令主要用来更新(启动或停止)和查询系统服务的运行级信息。

# yum remove sendmail  //此命令会remove掉mutt,mutt作为测试工具最好装上。

之后安装apache

# yum -y install httpd 

# chkconfig httpd on 

# service httpd restart


第一步要先搭建DNS服务器:

修改主机名称:

# vi /etc/hosts  

192.168.1.15 mail.test.com  //mailserver的domain将是test.com

保存之后安装相关软件

#yum install bind*

BIND配置文件保存在:
/etc/named.conf    主配置文件
/var/named/         域zone文件位置

#vi /etc/named.conf

修改下面红色位置的内容

// See /usr/share/doc/bind*/sample/ for example named configuration files.
//


options {
listen-on port 53 { any; };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
        statistics-file "/var/named/data/named_stats.txt";
        memstatistics-file "/var/named/data/named_mem_stats.txt";
allow-query     { any; };
recursion yes;

dnssec-enable yes;
dnssec-validation yes;
dnssec-lookaside auto;

/* Path to ISC DLV key */
bindkeys-file "/etc/named.iscdlv.key";

managed-keys-directory "/var/named/dynamic";
};

在结尾处追加如下红色内容:

logging {
        channel default_debug {
                file "data/named.run";
                severity dynamic;
        };
};


zone "test.com" IN {
type master;
file "test.com";
        allow-update{none;};
};


zone "45.168.192.in-addr.arpa" IN {
type master;
file "45.168.192.local";
        allow-update{none;};
};



zone "." IN {
type hint;
file "named.ca";
};


include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";

保存退出文件。

配置正向解析

#cd /var/named/

#cp named.localhost test.com

#vim test.com

修改为如下内容,注意结尾的.

$TTL 86400
@ IN SOA dns.test.com.  root.test.com.   (
42 ; serial
3H ; refresh
15M ; retry
1W ; expire
1D ) ; minimum
IN       NS     dns.test.com.
        IN       MX   10     dns.test.com.
dns     IN       A           192.168.45.128
mail    IN       CNAME       dns
pop3    IN       CNAME       dns
smtp    IN       CNAME       dns
imap4    IN       CNAME       dns

配置反向解析

#cd /var/named/

#cp named.localhost 45.168.192.local

#vi 45.168.192.local

$TTL 86400
@ IN  SOA  dns.test.com. root.test.com. (
1997022700 ; serial
28800 ; refresh
14400 ; retry
3600000 ; expire
86400) ; minimum
IN   NS  dns.test.com.
128     IN   PTR dns.test.com.

 #chmod +r /var/named/*  //让刚新建的文件具有读取权限

# service named restart 

# chkconfig named on 

启动named无报错的话,来测试一下dns 

# netstat -tnl | grep 53 //确定named起来

#vi /etc/resolv.conf  //修改本机的DNS服务器指向 ,修改红色部分

# Generated by NetworkManager
domain localdomain
search test.com
nameserver 192.168.45.128

# service network restart //重启network服务 ,但有时修改后resolv的内容会丢失,这时可以不用这句话,再次修改上述文件即可。

测试DNS是否工作正常


安装openwebmail

$ su -
# cd /etc/yum.repos.d
# wget -q http://openwebmail.org/openwebmail/download/redhat/rpm/release/openwebmail.repo
# yum install openwebmail

安装dovecot

#yum install dovecot

修改dovecot配置文件

 #vim /etc/dovecot/dovecot.conf   //取消下述两行内容前面的#号

protocols = imap imaps  pop3 pop3s 

listen = *   

# service dovecot restart 

# chkconfig dovecot on 


关闭防火墙

#service iptables stop


安装cyrus-sasl

# yum -y install cyrus-sasl 

# chkconfig  saslauthd on 


修改 /etc/sysconfig/saslauthd

# vim /etc/sysconfig/saslauthd    

# Directory in which to place saslauthd's listening socket, pid file, and so 

# on.  This directory must already exist. 

SOCKETDIR=/var/run/saslauthd   

# Mechanism to use when checking passwords.  Run "saslauthd -v" to get a list 

# of which mechanism your installation was compiled with the ablity to use. 

MECH=shadow


修改 /etc/sasl2/smtpd.conf

# vim /usr/lib/sasl2/smtpd.conf 

pwcheck_method: saslauthd

mech_list: plain login


测试 saslauthd

# service saslauthd  restart 

# testsaslauthd  -u abc -p '123'

 0: OK "Success."


安装postfix

#yum install postfix

配置postfix

# vi /etc/postfix/main.cf

myhostname = mail.test.com
mydomain = test.com
myorigin = $mydomain
inet_interfaces = all    //把 inet_interfaces = localhost 注释掉
inet_protocols = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
mynetworks = 0.0.0.0/0 //允许接收所有网段发来的邮件,根据情况自行修改
relay_domains = $mydestination

在文件最后追加
smtpd_banner = $myhostname ESMTP $mail_name ($mail_version
default_process_limit = 50
default_destination_concurrency_limit = 20
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_application_name = smtpd
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination
smtpd_client_restrictions = permit_sasl_authenticated

#service postfix restart

# chkconfig postfix on


测试postfix、dovecot端口

#netstat -altpn|grep 25

 #netstat -altpn|grep 110 

#netstat -altpn|grep 143 

#netstat -altpn|grep 993 

#netstat -altpn|grep 995


配置openwebmail 

# vi /var/www/cgi-bin/openwebmail/etc/openwebmail.conf

domainnames                     test.com  

default_language                 zh_CN.GB2312 

default_timeoffset              +0800  

default_iconset                 Cool3D.Chinese.Simplified 

auth_module                   auth_unix.pl 

mailspooldir                  /var/spool/mail  

ow_cgidir                       /var/www/cgi-bin/openwebmail 

ow_cgiurl                       /cgi-bin/openwebmail  

ow_htmldir                      /var/www/data/openwebmail 

ow_htmlurl                      /data/openwebmail  

logfile                              /var/log/openwebmail.log


#vi /var/www/cgi-bin/openwebmail/etc/defaults/openwebmail.conf

domainnames             test  

smtpserver              192.168.45.128 

authpop3_server         192.168.45.128 

smtpport                25 

smtpauth                no 


# cd /var/www/cgi-bin/openwebmail

# ./openwebmail-tool.pl --init

Send the site report?(Y/n) 

Y sending report... 

Thank you.

最后重启一下阿帕奇

#service httpd restart

打开浏览器

输入192.168.45.128/webmail  (或者 mail.test.com/webmail,这个我只在128本机上通过,猜测其他机子连接应该修改其dns)

用户名输入 abc 输入密码即可。


可能出现问题:

如果出现了下面的问题  Couldn't create File /var/log/openwebmail.log! (Permission denied) 

在网上找到解决办法了:如下方面 运行: 

#touch /var/log/openwebmail.log 

#chcon -u system_u /var/log/openwebmail.log 
#chcon -t httpd_sys_script_rw_t /var/log/openwebmail.log 

#chcon -t httpd_unconfined_script_exec_t /var/www/cgi-bin/openwebmail/openwebmail*


我还遇到了一个问题,记不清了。大概是不能在/var/spool下面创建mai文件夹,解决方法是用root权限自己建立一个




参考资料:

1. http://wenku.baidu.com/link?url=y3cLkYRBr2YB1A5nQroDU-XzkShGUlIETf1Lr5YOLw3cYfwU5xdOflNqFAFlaqdBd8MXpEC2RC4kN6P7TlHAJmplKZZxL6u1blDHB0KCgAG

2. http://openwebmail.org/openwebmail/download/centos/el6/00.readme.txt

3. http://www.centoscn.com/CentosServer/lighttpd/2015/0611/5637.html

4. http://jingyan.baidu.com/article/414eccf60226f16b431f0ad3.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值