CentOS5.3+Nginx0.7.57+Postfix+Extmail邮件系统安装配置(三))-(注:里边一些内容引自原作者sery)

三.Webmail相关包安装
一.安装webmail
       安装前先安装 Unix-Syslog-1.1.tar.gz
http://search.cpan.org/CPAN/authors/id/M/MH/MHARNISCH/Unix-Syslog-1.1.tar.gz
 
Tar zxvf Unix-Syslog-1.1.tar.gz
cd Unix-Syslog-1.1
perl Makefile.PL
make
make install
安装: DBI-1.605.tar.gz( 先安装 )
DBD-mysql-4.010.tar.gz
 
      
安装extmail
    ……………………………安装开始………………………………………………
Shell> Mkdir -p /var/www/extsuite/extmail
       将下载的 extmail-1.0.4.tar.gz 解压到 /var/www/extsuite/extmail
       Shell> cd /var/www/extsuite/extmail/
Shell> cp webmail.cf.default webmail.cf
[Shell> chown �CR vmail.vmail /var/www/extsuite/extmail]
[shell> chmod +x  /var/www/extsuite/extmail/cgi]
……………………………安装结束………………………………………………
 
简易配置
1.        修改nginx nginx.conf 文件
#more /usr/local/nginx/conf/nginx.conf
user  vmail vmail;
worker_processes 8;
#error_log  /usr/local/nginx/logs/nginx_error.log  crit;
error_log  /usr/local/nginx/logs/nginx_error.log  info;

pid        /usr/local/nginx/nginx.pid;
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;
events
{
  use epoll;
  worker_connections 51200;
}
http
{
  include       mime.types;
  default_type  application/octet-stream;
  #charset  gb2312;
     
  server_names_hash_bucket_size 128;
  client_header_buffer_size 32k;
  large_client_header_buffers 4 32k;
  client_max_body_size 8m;
     
  sendfile on;
  tcp_nopush     on;
  keepalive_timeout 60;
  tcp_nodelay on;
  fastcgi_connect_timeout 300;
  fastcgi_send_timeout 300;
  fastcgi_read_timeout 300;
  fastcgi_buffer_size 64k;
  fastcgi_buffers 4 64k;
  fastcgi_busy_buffers_size 128k;
  fastcgi_temp_file_write_size 128k;
  gzip on;
  gzip_min_length  1k;
  gzip_buffers     4 16k;
  gzip_http_version 1.0;
  gzip_comp_level 2;
  gzip_types       text/plain application/x-javascript text/css application/xml;
  gzip_vary on;
  #limit_zone  crawler  $binary_remote_addr  10m;
  server
  {
    listen       80;
    server_name  mail.test.com;
    index index.html index.htm index.php index.cgi;
    root  /var/www/extsuite/extmail/html/;
   
      
    location  /extmail/cgi/ {
        fastcgi_pass  127.0.0.1:12009;
        fastcgi_index         index.cgi;
        fastcgi_param  SCRIPT_FILENAME   /var/www/extsuite/extmail/cgi/$fastcgi_script_name;
        include fcgi.conf;
   }
    location   ^~ /extmail/ {
        alias  /var/www/extsuite/extmail/html/;
   }
    location /extman/cgi/ {
        fastcgi_pass  127.0.0.1:12009;
        fastcgi_index         index.cgi;
        fastcgi_param  SCRIPT_FILENAME   /var/www/extsuite/extman/cgi/$fastcgi_script_name;
        include fcgi.conf;
   }
    location ^~ /extman/ {
        alias  /var/www/extsuite/extman/html/;
    }
  
  
    location ^~ /status {
       stub_status on;
       access_log   off;
       #allow 192.168.0.0/24;
       #deny all;
       allow 59.108.107.66;
    }
                     
   location ~ .*\.(php|php5)?$
    {     
      #fastcgi_pass  unix:/tmp/php-cgi.sock;
      fastcgi_pass  127.0.0.1:12009;
      fastcgi_index index.cgi;
      include fcgi.conf;
    }
   
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    {
      expires      30d;
    }
    location ~ .*\.(js|css)?$
    {
      expires      1h;
    }   
    log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
              '$status $body_bytes_sent "$http_referer" '
              '"$http_user_agent" $http_x_forwarded_for';
    access_log  /usr/local/nginx/logs/access.log  access;
      }
}
 
  2.extmail cgi脚本配置
   #MAXFORK=5
   MAXFORK=20
   #MAXREQS=100
   MAXREQS=500
   #TIMEOUT=120
   TIMEOUT=300
   PORT=12009  #端口号与nginx.conf文件保持一致,
   SU_UID=vmail
   SU_GID=vmail
 
   安装extman
……………………………安装开始………………………………………………
Shell> mv extman-0.2.3 /var/www/extsuite/extman
//Shell> chown -R vmail:vmail /var/www/extsuite/extman
创建 extman 运行时所需要临时目录
Shell> mkdir  -pv /tmp/extman
Shell> chown -R vmail.vmail /tmp/extman
初始化数据库时,请更改 init.sql extmail.org 的名称为自已域名
Shell> cd /var/www/extsuite/extman/docs/
//Shell> vi init.sql            
         extmail.org 全部替换为 mail.test.com ( 自己根据自己的域名替换 )
 
修改 cgi 目录的属主:
# chown -R vmail.vmail /var/www/extsuite/extman/cgi/
Shell> mysql -u root -p < ./extmail.sql    
Shell> mysql �Cu root �Cp < ./init.sql
 
Extmail extman 详细配置
1.        extmail 配置 vi  webmail.cf
SYS_USER_LANG = en_US  改为 SYS_USER_LANG = zh_CN
SYS_MAILDIR_BASE = /home/domains 右边改为 /var/mailbox
SYS_MYSQL_USER = db_user 右边改为 extmail
SYS_MYSQL_PASS = db_pass    右边改为 extmail
SYS_MYSQL_SOCKET = /var/lib/mysql/mysql.sock 右边改为 /usr/local/mysql/tmp/mysql.sock
SYS_AUTHLIB_SOCKET = /usr/local/authlib/var/spool/authdaemon/socket
………………………
2.        extman 配置 vi webman.cf
SYS_MAILDIR_BASE = /home/domains 右边改为 /var/mailbox
SYS_DEFAULT_UID = 1001
SYS_DEFAULT_GID = 1001
SYS_MYSQL_SOCKET = /usr/local/mysql/tmp/mysql.sock
SYS_CAPTCHA_ON = 0          // 关闭图形验证码
 
起动NGINX和extmail cgi
/var/www/extsuite/extmail/dispatch-init start
/usr/local/nginx/sbin/nginx
 
测试:
输入网址: http://mail.test.com/extmail/cgi/index.cgi
管理员账号 [email protected]     extmail*123*       
 
       FAQ:
Can't open /tmp/extman//sid_e438c6f837880729ff491bd3f7ea3f01, No such file or directory
       解决: mkdir  -pv /tmp/extman
       chown -R vmail.vmail /tmp/extman
       apache 运行用户及组为 vmail
二. 安装webmail 图形化日志
       1. RRDTool 安装
下载: http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.2.30.tar.gz
          http://ftp.gnome.org/pub/gnome/sources/libart_lgpl/2.3/libart_lgpl-2.3.20.tar.gz( 先安装 )
步骤:
--------------------------------------------------------------------------------------------------
libart
安装 ( 包括了 libart 库文件 , 对平面图形的良好性能很有帮助 )
# tar zxvf libart_lgpl-2.3.20.tar.gz && cd libart*
# ./configure --prefix=/usr/local/libart
# make && make install
RRDTool 安装 ( Rrdtool 依赖 libpng freetype libart 库支持,安装这个前应先保证这几个库已安装上 )
# tar zxvf rrdtool-1.2.30.tar.gz && cd rrd*
# more /doc/rrdbuild.txt ( 安装说明 )
# export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/libart/lib/pkgconfig
# pkg-config --libs freetype2(
检测一下是否可以找到 freetype2)
 -L/usr/local/lib -lfreetype -lz
# ./configure --prefix=/usr/local/rrdtool     // 本机需要连网
##############################################################################
配置信息:
----------------------------------------------------------------
Config is DONE!
 
          With MMAP IO: yes
          Perl Modules: perl_piped perl_shared
           Perl Binary: /usr/bin/perl
          Perl Version: 5.8.8
          Perl Options: PREFIX=/usr/local/rrdtool LIB=/usr/local/rrdtool/lib/perl/5.8.8
          Ruby Modules:
           Ruby Binary: no
          Ruby Options: sitedir=$(DESTDIR)/usr/local/rrdtool/lib/ruby
    Build Tcl Bindings: no
 Build Python Bindings: yes
          Build rrdcgi: yes
       Build librrd MT: yes
 
 
Type 'make' to compile the software and use 'make install' to
install everything to: /usr/local/rrdtool.
 
       ... that wishlist is NO JOKE. If you find RRDtool useful
make me happy. Go to http://tobi.oetiker.ch/wish and
place an order.
 
                               -- Tobi Oetiker <[email protected]>
---------------------------------------------------------------- ########################################################################
# make && make install
2 .安装 File-Tail perl 模块
下载: http://search.cpan.org/CPAN/authors/id/M/MG/MGRABNAR/File-Tail-0.99.3.tar.gz
基本步骤:
# tar zxvf File-Tail-0.99.3.tar.gz && cd File*
# perl Makefile.PL
# make && make install
以下是安装信息:
       cp Tail.pm blib/lib/File/Tail.pm
Manifying blib/man3/File::Tail.3pm
Installing /usr/lib/perl5/site_perl/5.8.8/File/Tail.pm
Installing /usr/share/man/man3/File::Tail.3pm
Writing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/File/Tail/.packlist
Appending installation info to /usr/lib/perl5/5.8.8/i386-linux-thread-multi/perllocal.pod
       3.启动图形日志服务测试
Shell> cp -r /var/www/extsuite/extman/addon/mailgraph_ext /usr/local/

其它设置: ( 因为 rrdtool 安装在非标准目录,所以其 perl 模块找不到 , 拷备到标准目录即可 )
cp -r /usr/local/rrdtool/lib/perl/5.8.8/i386-linux-thread-multi/* /usr/lib/perl5/5.8.8/i386-linux-thread-multi/
 
              shell> /usr/local/mailgraph_ext/mailgraph-init start  
           shell> /usr/local/mailgraph_ext/qmonitor-init start
           加入到开机启动 :
           Shell> echo “/usr/local/mailgraph_ext/mailgraph-init start”>>/etc/rc.local
           Echo > echo “/usr/local/mailgraph_ext/qmonitor-init start”>>/etc/rc.local
           图形日志测试
              测试页: http://mail.test.com/extman/cgi/index.cgi
              默认登录账号: [email protected]/ extmail*123*
三. 邮件系统配置测试补充
1.    postfix 配置
#########################################################
# more master.cf
# sed -e '/^#/d' -e '/^$/d' master.cf
smtp      inet  n       -       n       -       -       smtpd
pickup    fifo  n       -       n       60      1       pickup
cleanup   unix  n       -       n       -       0       cleanup
qmgr      fifo  n       -       n       300     1       qmgr
tlsmgr    unix  -       -       n       1000?   1       tlsmgr
rewrite   unix  -       -       n       -       -       trivial-rewrite
bounce    unix  -       -       n       -       0       bounce
defer     unix  -       -       n       -       0       bounce
trace     unix  -       -       n       -       0       bounce
verify    unix  -       -       n       -       1       verify
flush     unix  n       -       n       1000?   0       flush
proxymap  unix  -       -       n       -       -       proxymap
proxywrite unix -       -       n       -       1       proxymap
smtp      unix  -       -       n       -       -       smtp
relay     unix  -       -       n       -       -       smtp
        -o smtp_fallback_relay=
showq     unix  n       -       n       -       -       showq
error     unix  -       -       n       -       -       error
retry     unix  -       -       n       -       -       error
discard   unix  -       -       n       -       -       discard
local     unix  -       n       n       -       -       local
virtual   unix  -       n       n       -       -       virtual
lmtp      unix  -       -       n       -       -       lmtp
anvil     unix  -       -       n       -       1       anvil
scache    unix  -       -       n       -       1       scache
maildrop  unix  -       n       n       -       -       pipe
  flags=DRhu user=vmail:vmail argv=/usr/local/bin/maildrop -d ${recipient}
# more main.cf
[root@MailSer1 postfix]# sed -e '/^#/d' -e '/^$/d' main.cf
queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
myhostname = mail.test.com
mydomain = test.com
myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
unknown_local_recipient_reject_code = 550
mynetworks = 192.168.0.0/24,127.0.0.0/8
relay_domains = $mydestination
alias_maps = $alias_database
defer_transports = 
mail_spool_directory = /var/spool/mail
debug_peer_level = 2
debugger_command =
         PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
         ddd $daemon_directory/$process_name $process_id & sleep 5
sendmail_path = /usr/sbin/sendmail
newaliases_path = /usr/bin/newaliases
mailq_path = /usr/bin/mailq
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/local/man
sample_directory = /etc/postfix
readme_directory = no
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_invalid_hostname,reject_non_fqdn_hostname,reject_unknown_sender_domain,reject_non_fqdn_sender,reject_non_fqdn_recipient,reject_unknown_recipient_domain,reject_unauth_pipelining,reject_unauth_destination,permit
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $domain
smtpd_sasl_security_options = noanonymous
smtpd_sasl_application_name = smtpd
smtpd_banner = $myhostname ESMTP $mail_name ($mail_version)
virtual_mailbox_base = /var/mailbox
virtual_mailbox_maps = mysql:/etc/postfix/mysql/mysql_virtual_mailbox_maps.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql/mysql_virtual_domains_maps.cf
virtual_alias_maps = mysql:/etc/postfix/mysql/mysql_virtual_alias_maps.cf
virtual_uid_maps = static:1001       #vmail
virtual_gid_maps = static:1001       #vmai
virtual_transport = maildrop
maildrop_destination_recipient_limit = 1
maildrop_destination_concurrency_limit = 1
 
message_size_limit = 200000000
virtual_mailbox_limit = 20971520
virtual_create_maildirsize = yes
virtual_mailbox_extended = yes
virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql/mysql_virtual_mailbox_limit_maps.cf
virtual_mailbox_limit_override = yes
virtual_maildir_limit_message = Sorry, the user's maildir has overdrawn his diskspace quota, please try again later.
virtual_overquota_bounce = yes
mydestination =
添加为支持虚拟域和虚拟用户所用到的配置文件
 
1.        添加为支持虚拟域和虚拟用户所用到的配置文件
创建目录/etc/ postfix /mysql , 然后手动创建四个配置文件:mysql_virtual_alias_maps.cfmysql_virtual_domains_maps.cfmysql_virtual_mailbox_limit_maps.cfmysql_virtual_mailbox_maps.cf。这4个文件的内容分别如下:
* 也可以直接从extman解压包的docs目录下直接挎备以下几个文件*
 
Shell> mkdir �Cp /etc/ postfix /mysql
Shell> more mysql_virtual_alias_maps.cf
user = extmail
password = extmail
hosts = localhost
dbname = extmail
table = alias
select_field = goto
where_field = address
additional_conditions = AND active = '1'
shell> more mysql_virtual_domains_maps.cf
user = extmail
password = extmail
hosts = localhost
dbname = extmail
table = domain
select_field = domain
where_field = domain
additional_conditions = AND active = '1'
shell> more mysql_virtual_mailbox_limit_maps.cf
user = extmail
password = extmail
hosts = localhost
dbname = extmail
table = mailbox
select_field = quota
where_field = username
additional_conditions = AND active = '1'
 
shell> more mysql_virtual_mailbox_maps.cf
user = extmail
password = extmail
hosts = localhost
dbname = extmail
table = mailbox
select_field = maildir
where_field = username
additional_conditions = AND active = '1'
 
2.       webmail 登录美化
登录界面美化:
在文件 /var/www/extsuite/extmail/html/default/index.html 加入下面的标识,可以得到不同
<TR>
<TD><%domain%></TD>
<TD><select name="domain" size="1" class="input_select"></option><option value="mail.test.com">mail.test.com</option></select></TD>
</TR>
 
邮件域的下拉列表,从而方便用户的使用。
在文件 /var/www/extsuite/extman/html/default/index.html 加入下面的标识,可以得到不同
<!-- END ERRMSG -->
<input name=username value=[email protected] class=login_input>
 
3.       认证发信测试
登录 webmail, mail.test.com 域添加一用户 test 密码是 123456
[root@MailSer1 mailbox]# nc localhost 25
220 mail.test.com ESMTP Postfix (2.5.6)
ehlo mail.test.com
250-mail.test.com
250-PIPELINING
250-SIZE 200000000
250-VRFY
250-ETRN
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
auth login
334 VXNlcm5hbWU6
dGVzdA==
334 UGFzc3dvcmQ6
MTIzNDU2
235 2.7.0 Authentication successful
       4. webmail 管理账号
              管理账号 :[email protected]/123456
5. maillog 日志
第一次通过 webmail 本地账号发信日志 (/var/log/maillog)
   
具体操作 :
       通过 webmail 管理后台 , 添加 test/test1 两个账号 , 登录 test test1 发信
   #####################################################################
May 12 14:56:43 MailSer1 postfix/smtpd[2979]: connect from MailSer1[127.0.0.1]
May 12 14:56:43 MailSer1 postfix/smtpd[2979]: 7AE618166: client=MailSer1[127.0.0.1]
May 12 14:56:43 MailSer1 postfix/cleanup[2987]: 7AE618166: [email protected]
May 12 14:56:43 MailSer1 postfix/smtpd[2979]: disconnect from MailSer1[127.0.0.1]
May 12 14:56:43 MailSer1 postfix/qmgr[2185]: 7AE618166: [email protected], size=597, nrcpt=1 (queue active)
May 12 14:56:44 MailSer1 authdaemond: received userid lookup request: [email protected]
May 12 14:56:44 MailSer1 authdaemond: authmysql: trying this module
May 12 14:56:44 MailSer1 authdaemond: authmysqllib: connected. Versions: header 50041, client 50041, server 50041
May 12 14:56:44 MailSer1 authdaemond: SQL query: SELECT username, password, "", '1001', '1001', '/var/mailbox/', maildir, concat(quota,' S'), name, "" FROM mailbox WHERE username = '[email protected] (active='1')
May 12 14:56:44 MailSer1 authdaemond: Authenticated: sysusername=<null>, sysuserid=1001, sysgroupid=1001, homedir=/var/mailbox/, [email protected], fullname=test1, maildir=mail.test.com/test1/Maildir/, quota=5242880S S, options=<null>
May 12 14:56:44 MailSer1 authdaemond: Authenticated: clearpasswd=<null>, passwd=$1$zm0l1Fcg$1ITtak8xWkMyrnzSdhGEK0
May 12 14:56:44 MailSer1 postfix/pipe[2989]: 7AE618166: [email protected], relay=maildrop, delay=1, delays=0.22/0.09/0/0.72, dsn=2.0.0, status=sent (delivered via maildrop service)
May 12 14:56:44 MailSer1 postfix/qmgr[2185]: 7AE618166: removed
              ##############################################################
             
以下是登录test1 图片: 有了新邮件
      
         查看邮件内容:
             
              外部发信测试, 我已经做好了DNS 解析(mail.test.com)
             
现通过126 邮箱向test1 发信, 以下是maillog
############################################################
      
       May 12 15:05:24 MailSer1 postfix/smtpd[3161]: connect from m14-22.126.com[220.181.14.22]
May 12 15:05:24 MailSer1 postfix/smtpd[3161]: 65FF38166: client=m14-22.126.com[220.181.14.22]
May 12 15:05:24 MailSer1 postfix/cleanup[3169]: 65FF38166: message-id=<17317745.993581242112006936.JavaMail.coremail@bj126app107.126.com>
May 12 15:05:24 MailSer1 postfix/qmgr[2185]: 65FF38166: from=<[email protected]>, size=2254, nrcpt=1 (queue active)
May 12 15:05:24 MailSer1 postfix/smtpd[3161]: disconnect from m14-22.126.com[220.181.14.22]
May 12 15:05:24 MailSer1 authdaemond: received userid lookup request: [email protected]
May 12 15:05:24 MailSer1 authdaemond: authmysql: trying this module
May 12 15:05:24 MailSer1 authdaemond: authmysqllib: connected. Versions: header 50041, client 50041, server 50041
May 12 15:05:24 MailSer1 authdaemond: SQL query: SELECT username, password, "", '1001', '1001', '/var/mailbox/', maildir, concat(quota,' S'), name, "" FROM mailbox WHERE username = '[email protected]'  AND (active='1')
May 12 15:05:24 MailSer1 authdaemond: Authenticated: sysusername=<null>, sysuserid=1001, sysgroupid=1001, homedir=/var/mailbox/, [email protected], fullname=test1, maildir=mail.test.com/test1/Maildir/, quota=5242880S S, options=<null>
May 12 15:05:24 MailSer1 authdaemond: Authenticated: clearpasswd=<null>, passwd=$1$zm0l1Fcg$1ITtak8xWkMyrnzSdhGEK0
May 12 15:05:24 MailSer1 postfix/pipe[3171]: 65FF38166: [email protected], relay=maildrop, delay=0.19, delays=0.1/0.04/0/0.06, dsn=2.0.0, status=sent (delivered via maildrop service)
May 12 15:05:24 MailSer1 postfix/qmgr[2185]: 65FF38166: removed
###############################################################
查看test1 邮箱: 收信没有问题
向外部邮箱发信测试,也没有问题向外部邮箱发信测试, 也没有问题

你可能感兴趣的:(nginx,centos,postfix,休闲,ExtMail)