下载:
extman-1.0.0.tar.gz
http://www.extmail.org/download
courier-authlib
安装数据库
- [root@mail src]# tar -zxvf extman-1.0.0.tar.gz
- [root@mail src]# cd extman-1.1
- [root@mail extman-1.1]# /usr/local/mysql/bin/mysql -u root -p < docs/extmail.sql
- Enter password:
- [root@mail extman-1.1]# /usr/local/mysql/bin/mysql -u root -p < docs/init.sql
- Enter password:
配置
- [root@mail extman-1.1]# vi /etc/postfix/main.cf
- // 注释掉
- 164 #mydestination = $myhostname localhost.$mydomain $mydomain
- // 添加:
- 661 # virtual user support
- 662 virtual_mailbox_base = /mailbox
- 663 virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
- 664 virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
- 665 virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
- 666 virtual_uid_maps = static:1000
- 667 virtual_gid_maps = static:1000
- // 建立虚拟用户映射表文件
- [root@mail extman-1.1]# cp docs/mysql_virtual_* /etc/postfix/
支持SMTP认证
- 安装courier-authlib
- [root@mail src]# tar jxvf courier-authlib-0.63.0.tar.bz2
- [root@mail src]# cd courier-authlib-0.63.0
- [root@mail courier-authlib-0.63.0]# ./configure --prefix=/usr/local/courier-authlib --without-stdheaderdir --with-authmysql --with-mysql-libs=/usr/local/mysql/lib/mysql --with-mysql-includes=/usr/local/mysql/include/mysql/
- [root@mail courier-authlib-0.63.0]# make && make install
- [root@mail courier-authlib-0.63.0]# make install-configure # 生成默认配置文件
- 上面的命令会生成 authmysqlrc和authdaemonrc作用分别为
- authdaemonrc: 主配置, 设置使用的认证方式
- authmysqlrc: 数据库配置文件,设置连接地址、查询方式等
- 修改主配文件,authdaemonrc
- [root@mail courier-authlib-0.63.0]# cd /usr/local/courier-authlib/
- [root@mail courier-authlib]# vi etc/authlib/authdaemonrc
- 27 #authmodulelist="authuserdb authpam authldap authmysql authcustom authpipe"
- 28 authmodulelist="authmysql"
- 34 #authmodulelistorig="authuserdb authpam authldap authmysql authcustom authpipe"
- 35 authmodulelistorig="authmysql"
- [root@mail courier-authlib]# vi etc/authlib/authmysqlrc
- 26 MYSQL_SERVER localhost # Mysql服务器的位置
- 27 MYSQL_USERNAME extmail # MySQL登录用户名
- 28 MYSQL_PASSWORD extmail # MySQL登录密码
- 49 MYSQL_SOCKET /var/mysql/mysql.sock # 去掉前面的#号
- 68 MYSQL_DATABASE extmai # MySQL数据库名字
- 83 MYSQL_USER_TABLE mailbox # MySQL用户邮箱存储的表的名字
- 133 MYSQL_HOME_FIELD concat('/mailbox/',homedir) # 用户宿主目录完整路径
- 150 MYSQL_MAILDIR_FIELD concat('/mailbox/',maildir) # 用户的完成邮件存储路径(去掉前面的#号)
- // 修改smtpd.conf,改为通过authdaemond进行认证
- [root@mail courier-authlib]# vi /usr/lib/sasl2/smtp.conf
- pwcheck_method:saslauthd
- authdaemond_path:/usr/local/couier-authlib/var/spool/authdaemon/socket
- // 调整socket目录权限
- [root@mail courier-authlib]# chmod -R 755 var/spool/authdaemon/
- // 添加库文件搜索路径
- [root@mail courier-authlib]# vi /etc/ld.so.conf
- /usr/local/courier-authlib/lib/courier-authlib
- [root@mail courier-authlib]# ldconfig
- // 启动courier-authlib
- [root@mail courier-authlib]# cp /usr/src/courier-authlib-0.63.0/courier-authlib.sysvinit /etc/init.d/courier-authlib
- [root@mail courier-authlib]# chmod 755 /etc/init.d/courier-authlib
- [root@mail courier-authlib]# service courier-authlib start
- Starting Courier authentication services: authdaemond
配置dovecot支持虚拟用户
- [root@mail courier-authlib]# vi /etc/dovecot/conf.d/10-mail.conf
- 24 mail_location = maildir:/mailbox/%d/%n/Maildir
- [root@mail courier-authlib]# cd /etc/dovecot
- [root@mail dovecot]# vi conf.d/10-auth.conf
- 注释掉121,去掉122的注释
- 121 #!include auth-system.conf.ext
- 122 !include auth-sql.conf.ext
- [root@mail dovecot]# vi dovecot-sql.conf.ext
- 29 driver = driver
- 66 connect = host=localhost dbname=extmail user=extmail password=extmail
- 73 default_pass_scheme = CRYPT
- 102 password_query = \
- 103 SELECT username AS user, password AS password \
- 104 FROM mailbox WHERE username = '%u'
- 122 user_query = \
- 123 SELECT maildir, uidnumber AS uid, gidnumber AS gid \
- 124 FROM mailbox WHERE username = '%u'
- // 简历邮箱目录,并调整权限
- [root@mail dovecot]# mkdir -p /mailbox/extmail.org/postmaster/Maildir
- [root@mail dovecot]# chown -R postfix.postfix /mailbox/
- [root@mail dovecot]# kill `pgrep dovecot`; dovecot # 重启dovecot
部署Extmail邮件使用界面
安装依赖:
下载:
Unix-Syslog-1.1.tar.gz
DBI-1.616.tar.gz
DBD-mysql-4.019.tar.gz
- [root@mail src]# wget http://search.cpan.org/CPAN/authors/id/M/MH/MHARNISCH/Unix-Syslog-1.1.tar.gz
- [root@mail src]# wget http://search.cpan.org/CPAN/authors/id/T/TI/TIMB/DBI-1.616.tar.gz
- [root@mail src]# wget http://search.cpan.org/CPAN/authors/id/C/CA/CAPTTOFU/DBD-mysql-4.019.tar.gz
- [root@mail src]# tar zxvf Unix-Syslog-1.1.tar.gz
- [root@mail src]# cd Unix-Syslog-1.1
- [root@mail Unix-Syslog-1.1]# perl Makefile.PL ;make ;make install
- [root@mail src]# tar -zxvf DBI-1.616.tar.gz
- [root@mail src]# cd DBI-1.616
- [root@mail DBI-1.616]# perl Makefile.PL && make && make install
- [root@mail src]# tar -zxvf DBD-mysql-4.019.tar.gz
- [root@mail DBD-mysql-4.019]# perl Makefile.PL --libs="-L/usr/local/mysql/lib/mysql -lmysqlclient -lz" -cflags=-I/usr/local/mysql/include/mysql && make && make install
安装extmail套件
- [root@mail extmail]# tar -zxvf extmail-1.2.tar.gz -C /usr/local/nginx/html/
- [root@mail src]# cd /usr/local/nginx/html
- [root@mail html]# mv extmail-1.2/ extmail
- [root@mail html]# cd extmail/
- [root@mail extmail]# mv webmail.cf.default webmail.cf
- [root@mail extmail]# vi webmail.cf
- 1 # sys_config, the config file and webmail programe root
- 2 SYS_CONFIG = /usr/local/nginx/html/extmail
- 3
- 4 # sys_langdir, the i18n dir
- 5 SYS_LANGDIR = /usr/local/nginx/html/extmail/lang
- 6
- 7 # sys_templdir, the template dir
- 8 SYS_TEMPLDIR = /usr/local/nginx/html/extmail/html
- 127 SYS_MAILDIR_BASE = /mailbox
- 139 SYS_MYSQL_USER = extmail
- 140 SYS_MYSQL_PASS = extmail
- 141 SYS_MYSQL_DB = extmail
- 142 SYS_MYSQL_HOST = localhost
- 143 SYS_MYSQL_SOCKET = /tmp/mysql.sock
这里由于使用nginx服务器作为WEB服务器,我们需要先配置nginx支持cgi,
可以参考这篇文章:http://linuxsvr.blog.51cto.com/2537584/643772
- # ifconfig eth0:0 192.168.3.3/24
我们这里的Nginx配置文件http { ….} 里添加一个基于ip和域名的虚拟主机:
- server{
- listen 192.168.3.3:80;
- server_name mail.gateway.org;
- location / {
- root /usr/local/nginx/html/extmail/html;
- }
- location /extmail/ {
- alias /usr/local/nginx/html/extmail/html/;
- }
- location /extmail/cgi/ {
- alias /usr/local/nginx/html/extmail/cgi/;
- }
- location ~.*\.cgi$ {
- fastcgi_pass 127.0.0.1:8999;
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
- include fastcgi_params;
- }
重启nginx
然后在浏览器里访问:mail.gateway.org(如果你配备了DNS服务器,并对这一条进行解析,可以这么访问,如果没有就基于ip访问,我没有配备DNS服务器所以就用ip访问)
使用用户名:postmaster 密码extmail 域extmail.org 登录
接下来我们开始extmail的管理界面
部署Extman WEB管理界面
依赖软件
GD-2.44.tar.gz # GD库
File-Tail-0.99.3.tar.gz # 日志分析
rrdtool-1.4.4-1.el5.wrl.i386.rpm # 数据画图工具
rrdtool-perl-1.4.4-1.el5.wrl.i386.rpm # rrdtool的相互依赖包
下载依赖包:
GD-2.44.tar.gz http://download.chinaunix.net/download.php?id=25978&ResourceID=3479
- File-Tail-0.99.3.tar.gz
- [root@mail src]# wget http://search.cpan.org/CPAN/authors/id/M/MG/MGRABNAR/File-Tail-0.99.3.tar.gz
- [root@mail src]# wget http://www.express.org/~wrl/rrdtool/rrdtool-1.4.4-1.el5.wrl.i386.rpm
- [root@mail src]# wget http://www.express.org/~wrl/rrdtool/rrdtool-perl-1.4.4-1.el5.wrl.i386.rpm
安装依赖:
- GD:
- [root@mail src]# yum -y install gd-devel # GD库依赖
- [root@mail src]# tar -zxvf GD-2.44.tar.gz
- [root@mail src]# cd GD-2.44
- [root@mail GD-2.44]# perl Makefile.PL
- [root@mail GD-2.44]# make && make install
- File-Tail
- [root@mail src]# tar -zxvf File-Tail-0.99.3.tar.gz
- [root@mail src]# cd File-Tail-0.99.3
- [root@mail File-Tail-0.99.3]# perl Makefile.PL
- [root@mail File-Tail-0.99.3]# make && make install
- rrdtool,rrdtool和rrdtoo-perl是相互依赖关系,必须一起装才不会报错:
- [root@mail src]# yum -y install ruby # rrdtool是用ruby写的,所以要先安装ruby
- [root@mail src]# rpm -ivh rrdtool-1.4.4-1.el5.wrl.i386.rpm rrdtool-perl-1.4.4-1.el5.wrl.i386.rpm
好了,现在我们开始安装Extman套件
安装
- [root@mail src]# tar -zxvf extman-1.0.0.tar.gz -C /usr/local/nginx/html/ # 解压到nginx的html目录
- [root@mail src]# cd /usr/local/nginx/html/
- [root@mail html]# mv extman-1.1/ extman # 重命名为extman
- [root@mail html]# chown -R postfix.postfix extman/cgi/ # 改变extman下cig的属主和属组为postfix运行账户
- [root@mail html]#vi extman/webman.cf # 编辑配置文件
- 1:SYS_CONFIG = /usr/local/nginx/html/extman/webman.cf
- 3:SYS_LANGDIR = /usr/local/nginx/html/extman/lang
- 5:SYS_TEMPLDIR = /usr/local/nginx/html/extman/html
- 7:SYS_MAILDIR_BASE = /mailbox
- 9:SYS_SHOW_WARN = 0
- 11:SYS_SESS_DIR = /var/extman # 系统当前会话文件的保存目录
- 131:SYS_MYSQL_SOCKET = /tmp/mysql.sock
- [root@mail html]# mkdir /var/extman ; chmod 777 /var/extman # 创建extman目录并给权限为777
- [root@mail html]# vi ../conf/nginx.conf # 调整nginx配置
- server{
- listen 192.168.3.3:80;
- server_name mail.gateway.org;
- location / {
- root /usr/local/nginx/html/extmail/html;
- }
- location /extmail/ {
- alias /usr/local/nginx/html/extmail/html/;
- }
- location /extmail/cgi/ {
- alias /usr/local/nginx/html/extmail/cgi/;
- }
- location /extman/ {
- alias /usr/local/nginx/html/extman/html/;
- }
- location /extman/cgi/ {
- alias /usr/local/nginx/html/extman/cgi/;
- }
- location ~.*\.cgi$ {
- fastcgi_pass 127.0.0.1:8999;
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
- include fastcgi_params;
- }
- }
- [root@mail html]# kill -9 `pgrep nginx` && /usr/local/nginx/sbin/nginx # 重启nginx
启用 mailgraph_ext 图形日志插件:
- [root@mail mailgraph_ext]# cd extman/addon/mailgraph_ext/
- [root@mail mailgraph_ext]# mkdir /usr/local/mailgraph_ext/
- [root@mail mailgraph_ext]# cp mailgraph_ext.pl /usr/local/mailgraph_ext/
- [root@mail mailgraph_ext]# cp qmonitor.pl /usr/local/mailgraph_ext/
- [root@mail mailgraph_ext]# ./mailgraph-init start
- [root@mail mailgraph_ext]# cd /usr/local/nginx/html/extman
- [root@mail extman]# daemon/cmdserver –daemon # 启动cmdserver ,如果不启动登录后台的时候会显示系统信息 No such file or directory
访问:http://192.168.3.3/extman/
用户名:[email protected] 密码:extmail*123* 域extmail.org
如果验证码不正确,把服务器的时间和本地之间调成一致.
现在就可以对邮件系统进行管理,添加域添加账户.查看图形日志(如果不显示则GD库安装有问题)
错误总结:
错误
访问http://192.168.3.3/extman/
502错误
查看日志
2011/08/20 15:55:45 [error] 24791#0: *11 FastCGI sent in stderr: "Prototype mismatch: sub Encode::IMAPUTF7::decode ($$;$) vs none at /usr/local/nginx/html/extman/libs/Encode/IMAPUTF7.pm line 76.
解决方法:
编辑extman/libs/Encode/IMAPUTF7.pm文件(修改之前注意备份)
将“no warnings 'redefine';^M”那一行修改成“no warnings;”
参考:http://www.extmail.org/forum/viewthread.php?tid=14393&page=1#pid82269
错误:
登录后台显示
待解决
错误:
添加域名的时候不会在/mailbox/下创建相应的文件夹
解决:
运行cgiwrap-fcgi.pl的时候用的root账户运行,而mailbox的数组和属主都是postfix所以要使用postfix运行perl-fcgi.
postfix是禁止登陆的,所以不能使用su postfix -c 的命令,Linux指定某个用户执行某个程序可以使用setuid
然后再运行就是已postfix用户运行的了
- [root@mail ~]# cd /usr/local/bin/
- [root@mail bin]# chown postfix.postfix cgiwrap-fcgi.pl
- [root@mail bin]# chmod +s cgiwrap-fcgi.pl
写完这点就忙去了,我试了,上面的弄完还是不行,用代码测试了权限什么都没问题,所以换了一个版本,换了extman-1.0.0.tar.gz就正常了.不知道是版本的问题还是个人问题.
还有文件夹不是创建域的时候创建应该是注册或添加用户的时候创建
本文出自 “cold night” 博客,转载请与作者联系!