Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1734751
  • 博文数量: 391
  • 博客积分: 8464
  • 博客等级: 中将
  • 技术积分: 4589
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-13 15:12
个人简介

狮子的雄心,骆驼的耐力,孩子的执著!

文章分类

全部博文(391)

文章存档

2023年(4)

2018年(9)

2017年(13)

2016年(18)

2014年(7)

2013年(29)

2012年(61)

2011年(49)

2010年(84)

2009年(95)

2008年(22)

分类: 系统运维

2012-03-30 13:59:49

1、 安装apache(nginx)+php+mysql(不再介绍)

2、 如果有需要请架设bind服务器

3、 安装+dovecot+admin+mysql
需要安装以下软件:(一款MTA),admin(管理邮局帐号),cyrus-sasl(安全认证软件),dovecot(一款安全pop软件)
(1)添加mysql用户

#/opt/app/mysql/bin/mysql –u root –proot

mysql>create database ;

mysql>grant all privileges on .* to @localhost identified by '';
mysql>flush privileges;

(2)安装admin
#tar -zvxf admin-2.6.5.tar.gz
#mv admin-2.6.5 /opt/case/mail/admin
#cd /opt/case/mail/admin
#cp config.inc.php config.inc.php.bak
#vim config.inc.php

$CONF['configured'] = true;
$CONF['default_language'] = 'cn'; ###让admin 支持中文

$CONF['database_type'] = 'mysql';

$CONF['database_host'] = 'localhost';

$CONF['database_user'] = '';

$CONF['database_password'] = '';

$CONF['database_name'] = '';
$CONF['domain_in_mailbox'] = 'NO'; ###If you don't want to have the domain in your mailbox set this to 'NO'.
$CONF['encrypt'] = 'md5';
(3)配置apache访问admin
#vim /opt/app/apache/conf/httpd.conf

DocumentRoot /opt/case/mail/admin

Options FollowSymLinks
DirectoryIndex index.php index.html index.htm
AllowOverride None
AuthType Basic ###可以不用
authname Private ###可以不用
authuserfile /var/run/admin ###可以不用
require valid-user ###可以不用
Order allow,deny
Allow from all


(4)生成认证文件(如果在配置apache时没有启用AuthType Basic,本部骤省略。)
#/opt/app/apache/bin/htpasswd -c /var/run/admin admin

###其中/var/run/admin为文件名,最后的admin为用户名
ew password:
Re-type new password:
Adding password for user admin
###输入两次密码后生成用户admin
(5)运行安装向导前需要安装php的imap扩展
先安装依赖包,否则会报错
#yum -y install openssl openssl-devel pam pam-devel
#wget ftp://ftp.cac.washington.edu/mail/imap.tar.Z
#tar -zvxf imap.tar.z
#cd imap-2007e
#make lr5 PASSWDTYPE=std SSLTYPE=unix.nopwd IP6=4
#echo "set disable-plaintext nil" > /etc/c-client.cf
#mkdir /usr/local/imap-2007e
#mkdir /usr/local/imap-2007e/include/
#mkdir /usr/local/imap-2007e/lib/
#chmod -R 077 /usr/local/imap-2007e
#cp imapd/imapd /usr/sbin/
#cp c-client/*.h /usr/local/imap-2007e/include/
#cp c-client/*.c /usr/local/imap-2007e/lib/
#cp c-client/c-client.a /usr/local/imap-2007e/lib/libc-client.a
#cd /usr/local/src/php-5.2.12/ext/imap
#/opt/app/php/bin/phpize
#./configure --with-php-config=/opt/app/php/bin/php-config --with-imap-ssl --with-imap=/usr/local/imap-2007e
#make && make install
(6)编辑php.ini

改magic_quotes_gpc = Off

加入 extension = "imap.so"
重启apache
打开就可以开始admin的安装了,安装完后可以进行添加域和用户的操作
注:如装了php5-imap还是提示无imap,则直接改掉setup.php里的变为if ( $f_imap_open == 0) 跳过检查
设置setup密码

打开admin配置文件config.inc.php,找到$CONF['setup_password'] =‘changme’这一行,把值改为刚才setup生成的加密密码,如

“84ab1a59d0a50933fffb7cf2c3483ac9:65a5b14ab41e35c53c85f6806eb1182765ecf866”

输入管理员的邮箱 和密码点击 Add Admin 按扭

(7)安装cyrus-sasl
#tar -zvxf cyrus-sasl-2.1.23.tar.gz
#cd cyrus-sasl-2.1.23
#./configure --enable-login --enable-sql --with-mysql=/opt/app/mysql/
#make && make install
#ln -s /usr/local/lib/sasl2 /usr/lib/sasl2
(8)停用sendmail
#service sendmail stop
#chkconfig --level 345 sendmail off
#mv /usr/bin/newaliases /usr/bin/newaliases.orig
#mv /usr/bin/mailq /usr/bin/mailq.orig
#mv /usr/sbin/sendmail /usr/sbin/sendmail.orig

(9)安装
#groupadd -g 12345
#useradd -u 12345 -g -s /sbin/nologin -d /dev/null
#groupadd -g 54321 postdrop
#tar -zvxf -2.6.5.tar.gz
#cd -2.6.5
# make -f Makefile.init makefiles \

'CCARGS=-DHAS_MYSQL -I/opt/app/mysql/include/mysql -DUSE_SASL_AUTH -DDEF_SERVER_SASL_TYPE=\"dovecot\"' \

'AUXLIBS=-L/opt/app/mysql/lib/mysql -lmysqlclient -lz -lm'
#make && make install

注:如果提示bin/postconf: error while loading shared libraries: libmysqlclient.so.15: cannot open shared object file: No such file or directory错误,则解决方法如下:

#echo "/usr/local/mysql/lib/mysql">>/etc/ld.so.conf

#ldconfig

然后再重新make install,ok,安装好了。
然后下一步下一步默认就可以

(10)配置

①、设置main.cf

#cd /etc/

#mv main.cf main.cf .bak

#vim main.cf

command_directory = /usr/sbin

config_directory = /etc/

daemon_directory = /usr/libexec/

data_directory = /var/lib/

debug_peer_level = 2

html_directory = no

inet_interfaces = all

mail_owner =

mailbox_size_limit = 204800000 ###容量大小  200M = 200 * 1024 * 1000

mailq_path = /usr/bin/mailq

manpage_directory = /usr/local/man

message_size_limit = 51200000 ###限制附件大小 50M = 50 * 1024 * 1000,实际上传附件大小 = realsize + realsize * 30% 

mydomain = qihang001.com ###域名

myhostname = mail.qihang001.com ###主机名

mynetworks = 0.0.0.0/0 ###配置这一项使用用户可在任意地发送邮件

mynetworks_style = subnet

myorigin = $mydomain

newaliases_path = /usr/bin/newaliases

queue_directory = /var/spool/

readme_directory = no

sample_directory = /etc/

sendmail_path = /usr/sbin/sendmail

setgid_group = postdrop

###配置使用dovecot的sql认证

smtpd_banner = $myhostname ESMTP

smtpd_recipient_restrictions = permit_mynetworks, reject_invalid_hostname, reject_non_fqdn_hostname, reject_unknown_sender_domain, reject_non_fqdn_sender, reject_non_fqdn_recipi

ent, reject_unknown_recipient_domain, reject_unauth_pipelining, reject_unauth_destination

###上面这个smtpd_recipient_restrictions后面的项目每个逗号后都要有一个空格,否则会有问题

smtpd_sasl_auth_enable = yes

smtpd_sasl_local_domain =

smtpd_sasl_path = /var/run/dovecot/auth-client ###路径要与dovecot一样

smtpd_sasl_security_options = noanonymous

smtpd_sasl_type = dovecot ###定义安装方式 dovecot

unknown_local_recipient_reject_code = 550

###虚拟用户设定

virtual_alias_domains =

virtual_alias_maps = mysql:/etc//mysql_virtual_alias_maps.cf

virtual_gid_maps = static:12345

virtual_mailbox_base = /data/mailbox/ ###虚拟用户目录

virtual_mailbox_domains = mysql:/etc//mysql_virtual_domains_maps.cf

virtual_mailbox_limit = 209715200

virtual_mailbox_maps = mysql:/etc//mysql_virtual_mailbox_maps.cf

virtual_transport = virtual

virtual_uid_maps = static:12345

②、创建mysql通信文件

# vim /etc//mysql_virtual_alias_maps.cf
user =
password =
hosts = localhost
dbname =
table = alias
select_field = goto
where_field = address

#vim /etc//mysql_virtual_domains_maps.cf

user =
password =
hosts = localhost
dbname =
table = domain
select_field = description
where_field = domain

#vim /etc//mysql_virtual_mailbox_maps.cf

user =
password =
hosts = localhost
dbname =
table = mailbox
select_field = maildir
where_field = username
# start ###启动
(11)安装配置dovecot
#mkdir -p /data/mailbox
#chown -R . /data/mailbox
#useradd -d /dev/null -s /sbin/nologin dovecot
#tar zxf dovecot-1.2.9.tar.gz
#cd dovecot-1.2.9
#./configure --prefix=/opt/app/dovecot --sysconfdir=/etc/dovecot --with-sql --with-sql-drivers --with-mysql \

CPPFLAGS=-I/opt/app/mysql/include/mysql LDFLAGS=-L/opt/app/mysql/lib/mysql
#make && make install
vim /etc/dovecot/dovecot.conf
protocols=pop3 pop3s

listen=*

disable_plaintext_auth = no

ssl= no

auth_debug = yes

log_path = /var/log/pop3.log

mail_location =maildir:/data/mailbox/%u

pop3_uidl_format=%08Xu%08Xv

mail_uid = 12345

mail_gid = 12345

first_valid_uid = 12345

auth default {

mechanisms = PLAIN LOGIN

passdb sql {

args = /etc/dovecot/dovecot-sql.conf

}

userdb sql {

args = /etc/dovecot/dovecot-sql.conf

}

socket listen {

client {

path = /var/run/dovecot/auth-client

###这里对应 smtpd_sasl_path

mode = 0660

user =

group =

}

}

}


#vim /etc/dovecot/dovecot-sql.conf
driver = mysql

connect = host=localhost dbname= user= password=

default_pass_scheme = MD5

###这里修改为 MD5 是为了与 admin 想符合,不然验证不过去总提示密码错误!

password_query = SELECT password FROM mailbox WHERE username = '%u'

user_query = SELECT maildir, 12345 as uid, 12345 as gid FROM mailbox WHERE username = '%u'

# /opt/app/dovecot/sbin/dovecot ###启动dovecot
4、运行测试
(1)打开浏览器输入:

输入我们刚刚建立的管理账号和密码,登录

(2)登录后,点域名清单——>新建域,如图

(3)点虚拟用户清单——>新建邮箱,如图

(4)再添加一个用户

(5)用outlook进行

阅读(2897) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~