postfix下extmail+虚拟用户

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
云数据库 RDS MySQL,高可用系列 2核4GB
简介:

我用的rhel5.5的操作系统

装系统的时候默认只装了基本和中文支持

LAMP+postfix+dovecot的部分略过

我所有的postfix包都在/media下,网站的路径是在/usr/local/apache2/下

mysql在/usr/local/mysql

cd /media/

tar -zxvf extman-0.2.5.tar.gz -C /usr/src
cd /usr/src/extman-0.2.5/docs/
mysql -u root -p < extmail.sql
mysql -u root -p < init.sql
vim /etc/postfix/main.cf
21  #mydestination = $mydomain, $myhostname
virtual_mailbox_base = /mailbox
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_uid_maps = static:1000
virtual_gid_maps = static:1000
cp  mysql_virtual_*  /etc/postfix
cd /media/
tar jxf courier-authlib-0.60.2.tar.bz2 -C /usr/src/
cd /usr/src/courier-authlib-0.60.2/
./configure --prefix=/usr/local/courier-authlib --without-stdheaderdir --with-authmysql --with-redhat --with-mysql-libs=/usr/local/mysql/lib/mysql --with-mysql-includes=/usr/local/mysql/include/mysql
make && make install
make install-configure
echo "/usr/local/courier-authlib/lib/courier-authlib" >> /etc/ld.so.conf
ldconfig
cd  /usr/local/courier-authlib/etc/authlib
vim authdaemonrc
27 authmodulelist="authmysql"
34 authmodulelistorig="authmysql"
chmod -R 755 /usr/local/courier-authlib/var/spool/authdaemon
vim  authmysqlrc
26 MYSQL_SERVER localhost //mysql数据库服务器位置 
27 MYSQL_USERNAME extmail //管理员帐号 
28 MYSQL_PASSWORD extmail //密码
49 MYSQL_SOCKET /tmp/mysql.sock 
68 MYSQL_DATABASE extmail //虚拟用户数据库 
83 MYSQL_USER_TABLE mailbox //从mailbox表获取邮件账户信息
92 MYSQL_CRYPT_PWFIELD password //从password获取密码
113 MYSQL_UID_FIELD uidnumber //从uidnumber字段映射本地uid 
119 MYSQL_GID_FIELD gidnumber //从gidnumber字段映射本地gid 
128 MYSQL_LOGIN_FIELD username 
133 MYSQL_HOME_FIELD concat('/mailbox/',homedir) 
139 MYSQL_NAME_FIELD name 
150 MYSQL_MAILDIR_FIELD concat('/mailbox/',maildir)

cp /usr/src/courier-authlib-0.60.2/courier-authlib.sysvinit /etc/init.d/courier-authlib
chmod 755 /etc/init.d/courier-authlib
chkconfig courier-authlib on
service courier-authlib start
vim /usr/lib/sasl2/smtpd.conf
pwcheck_method:authdaemond 
authdaemond_path:/usr/local/courier-authlib/var/spool/authdaemon/socket 
vim  /etc/dovecot.conf
208#mail_location = maildir:~/Maildir     (将此行#注释,改为下行)
mail_location = maildir:/mailbox/%d/%n/Maildir
auth default {
   mechanisms = plain
829   passdb sql {
856     args = /etc/dovecot-mysql.conf
}
928   userdb sql {
934       args = /etc/dovecot-mysql.conf
}
vim /etc/dovecot-mysql.conf
driver = mysql
connect = host=localhost dbname=extmail user=extmail password=extmail
default_pass_scheme = CRYPT
password_query = SELECT username AS user,password AS password FROM mailbox WHERE username = '%u'
user_query = SELECT maildir,uidnumber AS uid,gidnumber AS gid FROM mailbox WHERE username = '%u'
mkdir -p /mailbox/extmail.org/postmaster/Maildir
chown -R postfix:postfix /mailbox
pkill  dovecot
dovecot
测试:
/usr/local/courier-authlib/sbin/authtest -s login postmaster@extmail.org extmail

部署ExtMail邮件
tar -zxvf Unix-Syslog-1.1.tar.gz  -C  /usr/src
tar -zxvf DBI-1.607.tar.gz  -C  /usr/src
tar -zxvf DBD-mysql-4.011.tar.gz  -C  /usr/src
tar -zxvf extmail-1.0.5.tar.gz  -C /usr/local/apache2/htdocs
cd /usr/src/Unix-Syslog-1.1
perl Makefile.PL
make 
make install
cd ../DBI-1.607
perl Makefile.PL
make 
make install
cd ../DBD-mysql-4.011
perl Makefile.PL --libs="-L/usr/local/mysql/lib/mysql -lmysqlclient -lz" --cflags=-I/usr/local/mysql/include/mysql
make 
make install
cd /usr/local/apache2/htdocs
mv extmail-1.0.5/ extmail
cd extmail
chown  -R postfix:postfix cgi
cp webmail.cf.default  webmail.cf

vim  webmail.cf
2 SYS_CONFIG = /usr/local/apache2/htdocs/extmail/
5 SYS_LANGDIR = /usr/local/apache2/htdocs/extmail/lang
8 SYS_TEMPLDIR = /usr/local/apache2/htdocs/extmail/html
112 SYS_MAILDIR_BASE = /mailbox
124 SYS_MYSQL_USER = extmail
125 SYS_MYSQL_PASS = extmail
126 SYS_MYSQL_DB = extmail
127 SYS_MYSQL_HOST = localhost
128 SYS_MYSQL_SOCKET = /tmp/mysql.sock

vim /usr/local/apache2/conf/httpd.conf
66 User postfix
67 Group postfix
390 Include conf/extra/httpd-vhosts.conf
vim /usr/local/apache2/conf/extra/httpd-vhosts.conf
NameVirtualHost *:80
<VirtualHost *:80>
    DocumentRoot "/usr/local/apache2/htdocs/extmail/html"
    ServerName mail.quantanetwork.com       ScriptAlias /extmail/cgi/ /usr/local/apache2/htdocs/extmail/cgi/
    Alias /extmail /usr/local/apache2/htdocs/extmail/html/
 </VirtualHost>

/usr/local/apache2/bin/apachectl restart

部署Extman
cd /media
tar -zxvf  GD-2.41.tar.gz -C /usr/src
tar &ndash;zxvf  File-Tail-0.99.3.tar.gz  -C /usr/src/
tar -zxvf extman-0.2.5.tar.gz -C /usr/local/apache2/htdocs/
cd /usr/src/GD-2.41
yum -y install gd-devel
perl Makefile.PL
make  && make install 
cd ../File-Tail-0.99.3
perl Makefile.PL
make  && make install
rpm  -ivh rrdtool-1.2.23-3.el5.i386.rpm
rpm  -ivh rrdtool-perl-1.2.23-3.el5.i386.rpm
cd  /usr/local/apache2/htdocs 
mv extman-0.2.5   extman
chown -R postfix:postfix /usr/local/apache2/htdocs/extman/cgi
mkdir /tmp/extman
chown  -R postfix:postfix  /tmp/extman
vim /usr/local/apache2/htdocs/extman/webman.cf
2 SYS_CONFIG = /usr/local/apache2/htdocs/extman/
5 SYS_LANGDIR = /usr/local/apache2/htdocs/extman/lang
8 SYS_TEMPLDIR = /usr/local/apache2/htdocs/extman/html
12 SYS_MAILDIR_BASE = /mailbox
127 SYS_MYSQL_USER = webman
128 SYS_MYSQL_PASS = webman
129 SYS_MYSQL_DB = extmail
130 SYS_MYSQL_HOST = localhost
131 SYS_MYSQL_SOCKET = /tmp/mysql.sock

 vim /usr/local/apache2/conf/extra/httpd-vhosts.conf
<VirtualHost *:80>
    DocumentRoot "/usr/local/apache2/htdocs/extmail/html"
    ServerName mail.quantanetwork.com
    ScriptAlias /extmail/cgi/ /usr/local/apache2/htdocs/extmail/cgi/
    Alias /extmail /usr/local/apache2/htdocs/extmail/html/
    //新加入以下两行
    ScriptAlias /extman/cgi/ /usr/local/apache2/htdocs/extman/cgi/   
    Alias /extman /usr/local/apache2/htdocs/extman/html/
</VirtualHost>
 

注意:

如果你网站服务器的网页跟extmail的网页在同一台机器的话

那么你就需要做虚拟主机,否则会默认访问到你的extmail

vim /usr/local/apache2/conf/extra/httpd-vhosts.conf
 在末尾添加如下几行 根据需求自己修改

<VirtualHost *:80>
    DocumentRoot "/usr/local/apache2/htdocs/"
    ServerName www.quantanetwork.com
    Errorlog   logs/www.quantanetwork.com.errerlog
    CustomLog  logs/www.quantanetwork.com.access.log common
</VirtualHost>
~            













本文转自谢无赖51CTO博客,原文链接:http://blog.51cto.com/xieping/944930 ,如需转载请自行联系原作者


相关实践学习
如何在云端创建MySQL数据库
开始实验后,系统会自动创建一台自建MySQL的 源数据库 ECS 实例和一台 目标数据库 RDS。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
存储 网络协议 Linux
Postfix + Extmail 企业邮件服务器搭建
ExtMail套件用于提供从浏览器中登录、使用邮件系统的Web操作界面,而Extman套件用于提供从浏览器中管理邮件系统的Web操作界面。它以GPL版权释出,设计初衷是希望设计一个适应当前高速发展的IT应用环境,满足用户多变的需求,能快速进行开发、改进和升级,适应能力强的webmail系统。
750 0
Postfix + Extmail 企业邮件服务器搭建