1、 安装apache(nginx)+php+mysql(不再介绍)
2、 如果有需要请架设bind服务器
3、
需要安装以下软件:postfix(一款MTA),postfixadmin(管理邮局帐号),cyrus-sasl(安全认证软件),dovecot(一款安全pop软件)
(1)添加mysql用户
#/opt/app/mysql/bin/mysql –u root –proot
mysql>create database postfix;
mysql>grant all privileges on postfix.* to postfix@localhost identified by 'postfix';
mysql>flush privileges;
(2)安装postfixadmin
#tar -zvxf postfixadmin-2.6.5.tar.gz
#mv postfixadmin-2.6.5 /opt/case/mail/postfixadmin
#cd /opt/case/mail/postfixadmin
#cp config.inc.php config.inc.php.bak
#vim config.inc.php
$CONF['configured'] = true;
$CONF['default_language'] = 'cn';
$CONF['database_type'] = 'mysql';
$CONF['database_host'] = 'localhost';
$CONF['database_user'] = 'postfix';
$CONF['database_password'] = 'postfix';
$CONF['database_name'] = 'postfix';
$CONF['domain_in_mailbox'] = 'NO';
$CONF['encrypt'] = 'md5';
(3)配置apache访问postfixadmin
#vim /opt/app/apache/conf/httpd.conf
<VirtualHost *:80>
DocumentRoot /opt/case/mail/postfixadmin
<Directory " /opt/case/mail/postfixadmin">
</Directory>
</VirtualHost>
(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
①、打开http://mail.qihang001.com/setup.php就可以开始postfixadmin的安装了,安装完后可以进行添加域和用户的操作
注:如装了php5-imap还是提示无imap,则直接改掉setup.php里的变为if ( $f_imap_open == 0)
②、设置setup密码
③、打开postfixadmin配置文件config.inc.php,找到$CONF['setup_password'] =‘changme’这一行,把值改为刚才setup生成的加密密码,如
“84ab1a59d0a50933fffb7cf2
④、输入管理员的邮箱 和密码点击 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)安装postfix
#groupadd -g 12345 postfix
#useradd -u 12345 -g postfix -s /sbin/nologin -d /dev/null postfix
#groupadd -g 54321 postdrop
#tar -zvxf postfix-2.6.5.tar.gz
#cd postfix-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,postfix安装好了。
然后下一步下一步默认就可以
(10)配置postfix
①、设置main.cf
#cd /etc/postfix
#mv main.cf main.cf .bak
#vim main.cf
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
html_directory = no
inet_interfaces = all
mail_owner = postfix
mailbox_size_limit = 209715200
mailq_path = /usr/bin/mailq
manpage_directory = /usr/local/man
message_size_limit = 52428800
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/postfix
readme_directory = no
sample_directory = /etc/postfix
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
smtpd_sasl_security_options = noanonymous
smtpd_sasl_type = dovecot
unknown_local_recipient_reject_code = 550
###虚拟用户设定
virtual_alias_domains =
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_gid_maps = static:12345
virtual_mailbox_base = /data/mailbox/
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_mailbox_limit = 209715200
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_transport = virtual
virtual_uid_maps = static:12345
②、创建mysql通信文件
# vim /etc/postfix/mysql_virtual_alias_maps.cf
user = postfix
password = postfix
hosts = localhost
dbname = postfix
table = alias
select_field = goto
where_field = address
#vim /etc/postfix/mysql_virtual_domains_maps.cf
user = postfix
password = postfix
hosts = localhost
dbname = postfix
table = domain
select_field = description
where_field = domain
#vim /etc/postfix/mysql_virtual_mailbox_maps.cf
user = postfix
password = postfix
hosts = localhost
dbname = postfix
table = mailbox
select_field = maildir
where_field = username
#postfix start
(11)安装配置dovecot
#mkdir -p /data/mailbox
#chown -R postfix.postfix /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 {
###这里对应 postfix
}
#vim /etc/dovecot/dovecot-sql.conf
driver = mysql
connect = host=localhost dbname=postfix user=postfix password=postfix
default_pass_scheme = MD5
###这里修改为 MD5 是为了与 postfixadmin 想符合,不然验证不过去总提示密码错误!
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
4、运行测试
(1)打开浏览器输入:http://mail.qihang001.com
输入我们刚刚建立的管理账号和密码,登录
(2)登录后,点域名清单——>新建域,如图
(3)点虚拟用户清单——>新建邮箱,如图
(4)再添加一个用户
(5)用outlook进行测试
注:中途遇到什么问题,多看看dovecot,postfix 日志,和mysql 日志
自由广告区 |
分类导航 |
邮件新闻资讯: IT业界 | 邮件服务器 | 邮件趣闻 | 移动电邮 电子邮箱 | 反垃圾邮件|邮件客户端|网络安全 行业数据 | 邮件人物 | 网站公告 | 行业法规 网络技术: 邮件原理 | 网络协议 | 网络管理 | 传输介质 线路接入 | 路由接口 | 邮件存储 | 华为3Com CISCO技术 | 网络与服务器硬件 操作系统: Windows 9X | Linux&Uinx | Windows NT Windows Vista | FreeBSD | 其它操作系统 邮件服务器: 程序与开发 | Exchange | Qmail | Postfix Sendmail | MDaemon | Domino | Foxmail KerioMail | JavaMail | Winwebmail |James Merak&VisNetic | CMailServer | WinMail 金笛邮件系统 | 其它 | 反垃圾邮件: 综述| 客户端反垃圾邮件|服务器端反垃圾邮件 邮件客户端软件: Outlook | Foxmail | DreamMail| KooMail The bat | 雷鸟 | Eudora |Becky! |Pegasus IncrediMail |其它 电子邮箱: 个人邮箱 | 企业邮箱 |Gmail 移动电子邮件:服务器 | 客户端 | 技术前沿 邮件网络安全: 软件漏洞 | 安全知识 | 病毒公告 |防火墙 攻防技术 | 病毒查杀| ISA | 数字签名 邮件营销: Email营销 | 网络营销 | 营销技巧 |营销案例 邮件人才:招聘 | 职场 | 培训 | 指南 | 职场 解决方案: 邮件系统|反垃圾邮件 |安全 |移动电邮 |招标 产品评测: 邮件系统 |反垃圾邮件 |邮箱 |安全 |客户端 |