Centos 6.2_X86_64 編譯安裝postfix+amavisd-new+clamav

系統環境

CENTOS6.2 X86-64 並已經使用yum安裝配置好LNMP環境

以下是安裝所使用的部分軟件包

shell>cd /usr/local/src

shell>wget http://jaist.dl.sourceforge.net/project/courier/imap/4.16.0/courier-imap-4.16.0.tar.bz2

shell>wget ftp://ftp.cuhk.edu.hk/pub/packages/mail-server/postfix/official/postfix-2.11.4.tar.gz

shell>wget http://cznic.dl.sourceforge.net/project/courier/authlib/0.66.1/courier-authlib-0.66.1.tar.bz2

shell>wget ftp://ftp.cyrusimap.org/cyrus-sasl/cyrus-sasl-2.1.26.tar.gz

shell>wget ftp://ftp.cuhk.edu.hk/pub/packages/mail-server/postfix/official/postfix-2.11-patch04.gz

shell>wget http://cznic.dl.sourceforge.net/project/courier/courier-unicode/1.1/courier-unicode-1.1.tar.bz2

shell>wget http://jaist.dl.sourceforge.net/project/courier/maildrop/2.8.1/maildrop-2.8.1.tar.bz2

shell>wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.35.tar.bz2

shell>wget ftp://ftp.funet.fi/pub/languages/perl/CPAN/modules/by-module/DBD/DBD-mysql-4.031.tar.gz

shell>wget ftp://ftp.funet.fi/pub/languages/perl/CPAN/modules/by-module/DBI/DBI-1.633.tar.gz

shell>wget http://www.cpan.org/modules/by-module/FCGI/FCGI-0.77.tar.gz

shell>wget http://search.cpan.org/CPAN/authors/id/G/GB/GBJK/FCGI-ProcManager-0.25.tar.gz

shell>wget http://search.cpan.org/CPAN/authors/id/I/IN/INGY/IO-All-0.86.tar.gz

shell>wget http://www.cpan.org/authors/id/M/MH/MHARNISCH/Unix-Syslog-1.1.tar.gz

shell>wget http://www.cpan.org/authors/id/M/MG/MGRABNAR/File-Tail-1.0.tar.gz

shell>wget http://jaist.dl.sourceforge.net/project/clamav/clamav/0.98.6/clamav-0.98.6.tar.gz

shell>wget http://www.ijs.si/software/amavisd/amavisd-new-2.10.1.tar.xz

shell>wget http://www.cpan.org/authors/id/J/JM/JMEHNLE/mail-spf/Mail-SPF-v2.9.0.tar.gz




安裝前準備工作

shell>yum -y groupinstall "Development tools"

shell>yum install libtool #安裝courier-authlib須要

shell>yum install libtool-ltdl-devel #安裝courier-authlib須要

shell>yum install expect #安裝courier-authlib須要

shell>yum install gdbm-devel

shell>yum install libidn-devel

shell>yum install mysql-devel

shell>yum -y install db4-devel

創建組

shell>groupadd postfix -g 1000

shell>groupadd postdrop -g 1002

shell>useradd postfix -u 1000 -g postfix -G postdrop

shell>groupadd vmail -g 1001

shell>useradd vmail -u 1001 -g 1001 -M -s /bin/false


配置配置Nginx支持FCGI

shell>yum install perl-ExtUtils-Embed

shell>yum install perl-CGI

shell>cd /usr/local/src/

shell>tar -zxvf FCGI-0.77.tar.gz

shell>cd FCGI-0.77

shell>perl Makefile.PL

shell>make && make install

shell>cd ..

shell>tar -zxvf FCGI-ProcManager-0.25.tar.gz

shell>cd FCGI-ProcManager-0.25

shell>perl Makefile.PL

shell>make && make install

shell>cd ..

shell>tar zxvf IO-All-0.86.tar.gz

shell>cd IO-All-0.86

shell>perl Makefile.PL

shell>make && make install


shell>tar -zxvf Unix-Syslog-1.1.tar.gz

shell>cd Unix-Syslog-1.1

shell>perl Makefile.PL

shell>make && make install

shell>cd ..

shell>tar -zxvf DBD-mysql-4.031.tar.gz

shell>cd DBD-mysql-4.031

shell>perl Makefile.PL

shell>make && make install

shell>cd ..

shell>tar -zxvf DBI-1.633.tar.gz

shell>cd DBI-1.633

shell>perl Makefile.PL

shell>make && make install


卸載系統自帶的POSTFIX

shell>rpm -qa |grep postfix

shell>groupadd -g 1000 postfix

shell>useradd -g postfix -u 1000 postfix -s /sbin/nologin 

shell>groupadd -g 1002 postdrop


安裝courier-authlib

shell>cd /usr/local/src/

shell>tar -jxvf courier-authlib-0.66.1.tar.bz2 

shell>cd courier-authlib-0.66.1

shell>./configure    --prefix=/usr/local/courier-authlib --with-mailuser=vmail --with-mailgroup=vmail   --without-stdheaderdir  --without-authpam    --without-authldap    --without-authpwd    --without-authshadow     --without-authpgsql --with-authmysql    --with-redhat    CFLAGS="-march=x86-64 -O2 -fexpensive-optimizations" CXXFLAGS="-march=x86-64 -O2 -fexpensive-optimizations"  

shell>make 

shell>make install

shell>make install-configure

shell>cd /usr/local/courier-authlib/etc/authlib/

shell>cp authdaemonrc authdaemonrc.back

shell>vi authdaemonrc

authmodulelist="authmysql"

authmodulelistorig="authmysql"

DEBUG_LOGIN=2

修改上面3項,其他的項保持不變。這個修改前2行表示用mysql認證模塊;把DEBUG_LOGIN的值有默認的“0”改成“2”的用意是運行postfix時有更多的信息輸出,通過生成的日誌以幫助排錯。

shell>cp authmysqlrc authmysqlrc.back

shell>vi authmysqlrc

MYSQL_SERVER localhost

MYSQL_USERNAME extmail

MYSQL_PASSWORD extmail

MYSQL_DATABASE extmail

MYSQL_SOCKET /var/lib/mysql/mysql.sock

MYSQL_PORT              3306

MYSQL_USER_TABLE mailbox

MYSQL_CRYPT_PWFIELD password  //這裏需要注意

#MYSQL_CLEAR_PWFIELD password

DEFAULT_DOMAIN mail.test.com

MYSQL_UID_FIELD ‘1001’

MYSQL_GID_FIELD ‘1001’

MYSQL_LOGIN_FIELD username

MYSQL_HOME_FIELD '/var/mailbox/'

MYSQL_NAME_FIELD name

MYSQL_MAILDIR_FIELD maildir

MYSQL_QUOTA_FIELD concat(quota,'S')

MYSQL_WHERE_CLAUSE active='1'

shell> ln -s /usr/local/courier-authlib/include/* /usr/include/

shell>cp courier-authlib.sysvinit /etc/init.d/courier-authlib

chmod +x /etc/init.d/courier-authlib

chkconfig --add courier-authlib

chkconfig courier-authlib on

service courier-authlib start


安裝cyrus-sasl

先卸載系統自帶的cyrus-sasl 

shell>rpm -e cyrus-sasl

shell>rpm -e --nodeps cyrus-sasl-lib

    

shell>cd /usr/local/src/

shell>tar -zxvf cyrus-sasl-2.1.26.tar.gz 

shell>cd cyrus-sasl-2.1.26

shell>./configure --prefix=/usr/local/sasl2 --disable-sample   --disable-digest --disable-gssapi --disable-anon --enable-plain --enable-login --enable-sql  --with-authdaemond=/usr/local/courier-authlib/var/spool/authdaemon/socket  

shell>make

shell>make install

shell>ln -s /usr/local/sasl2/lib/sasl2 /usr/lib/

shell>ln -s /usr/local/sasl2/lib/sasl2 /usr/lib64/

shell>vi /etc/ld.so.conf

/usr/local/sasl2/lib/

/usr/local/sasl2/lib/sasl2

shell>ldconfig -v

shell>vi /usr/local/sasl2/lib/sasl2/smtpd.conf 

pwcheck_method: authdaemond

mech_list: PLAIN LOGIN

log_level: 3

authdaemond_path: /usr/local/courier-authlib/var/spool/authdaemon/socket

shell>chmod +x -R /usr/local/courier-authlib/var/spool/authdaemon/

shell>mkdir -pv /var/state/saslauthd #創建運行時須要的目錄

shell>/usr/local/sasl2/sbin/saslauthd -v #查看版本

shell>/usr/local/sasl2/sbin/saslauthd -a shadow pam -d #測試,正常的話不會報錯,如果沒有報錯.crtl+c結束掉進程

shell>/usr/local/sasl2/sbin/saslauthd -a shadow pam

shell>/usr/local/sasl2/sbin/testsaslauthd -u root -p 123456 #正常顯示0: OK "Success"表示成功(此處輸入的是系統登錄賬號root 的密碼,不是指的MySQL賬號密碼。否則會提示:

    0: NO "authentication failed",同時,注意這裏測試不用開啓authdaemond(authlib)

shell>echo "/usr/local/sasl2/sbin/saslauthd -a shadow pam" >>/etc/rc.local 

  

下載安裝相同版本的VDA補丁,使postfix支持磁盤限額,如果未安裝該補丁,POSTFIX配置磁盤限額後啓動POSTFIX會報錯

shell>tar -zxvf postfix-2.11.4.tar.gz 

shell>wget http://vda.sourceforge.net/VDA/postfix-vda-v13-2.11.4.patch

shell>patch -p1 <postfix-vda-v13-2.11.4.patch

安裝postfix

shell>cd postfix-2.11.4

shell>mkdir /var/mailbox

shell>chown vmail:vmail /var/mailbox/

shell>make Makefiles 'CCARGS=-DHAS_MYSQL -I/usr/include/mysql -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/local/sasl2/include/sasl' 'AUXLIBS=-L/usr/lib64/mysql -lmysqlclient -lz -lm -L/usr/local/sasl2/lib -lsasl2'

shell>make

shell>make install #默認回車完成安裝

shell>mv /etc/aliases /etc/aliases.old

shell>ln -s /etc/postfix/aliases /etc/aliases

shell>/usr/bin/newaliases #生成別名二進制文件,這個步驟如果忽略,會造成postfix效率極低

shell>/usr/sbin/postconf -a #正常顯示 cyrus dovecot

shell>/usr/sbin/postconf -m |grep mysql #正常顯示 mysql


安裝IMAP,須要先安裝courier-unicode,不然會報錯

shell>tar -jxvf courier-unicode-1.1.tar.bz2 

shell>cd courier-unicode-1.1

shell>./configure 

shell>make

shell>make install


安裝courier-imap

shell>tar -jxvf courier-imap-4.16.0.tar.bz2 

shell>cd courier-imap-4.16.0

shell>./configure --prefix=/usr/local/courier-imap  --with-redhat --enable-unicode=utf-8,iso-8859-1,gb2312,gbk,gb18030 --disable-root-check --with-trashquota --with-dirsync  --with-authmysql --with-authmysql=yes --without-ipv6 CPPFLAGS='-I/usr/local/courier-authlib/include' COURIERAUTHCONFIG='/usr/local/courier-authlib/bin/courierauthconfig'

shell>make

shell>make install

shell>make install-configure

shell>vi /usr/local/courier-imap/etc/pop3d

POP3DSTART=YES

MAILDIRPATH=/var/mailbox

shell>vi /usr/local/courier-imap/etc/imapd

IMAPDSTART=YES

MAILDIRPATH=/var/mailbox

shell>cp /usr/local/src/courier-imap-4.16.0/packaging/systemd/courier-imap.sysvinit /etc/rc.d/init.d/imapd

shell>chmod +x /etc/rc.d/init.d/imapd 

shell>chkconfig --add imapd

shell>chkconfig imapd on

shell>cd /usr/local/courier-imap/share

shell>./mkdhparams

shell>service imapd start

shell>netstat -tnl |egrep "110|143"


安裝maildrop

shell>cp /lib64/libpcre.so.0 /lib64/libpcre.so.0-old

shell>rpm -e --nodeps pcre

shell>tar -jxvf pcre-8.35.tar.bz2 

shell>cd pcre-8.35

shell>./configure 

shell>make

shell>make install

shell>ln -s /usr/local/courier/bin/courierauthconfig /usr/bin/courierauthconfig #這條命令很重要,沒有正常執行的話下面測試的時候Courier Authentication不會出現


shell>tar -jxvf maildrop-2.8.1.tar.bz2 

shell>cd maildrop-2.8.1

shell>./configure --enable-sendmail=/usr/sbin/sendmail  --enable-trusted-users='root vmail' --enable-syslog=1 --enable-maildirquota  --enable-maildrop-uid=1001  --enable-maildrop-gid=1001 --with-trashquota --with-dirsync

shell>make

shell>make install

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

shell>ldconfig -v

shell>maildrop -v

maildrop 2.0.4 Copyright 1998-2005 Double Precision, Inc.

GDBM extensions enabled.

Courier Authentication Library extension enabled.  #這行重要,沒有的話要查一下原因

Maildir quota extension enabled.

This program is distributed under the terms of the GNU General Public

License. See COPYING for additional information.


shell>vi /etc/maildroprc

logfile "/var/log/maildrop.log" 

to "$HOME/Maildir"

shell>touch /var/log/maildrop.log

shell>chown vmail:vmail /var/log/maildrop.log 


安裝配置extmail、extman

shell>mkdir /var/www/extsuite

shell>mount -o username=administrator,password=密碼 //192.168.1.103/download /mnt/

shell>cp /mnt/extma* .

shell>tar -zxvf extmail-1.2.tar.gz -C /var/www/extsuite

shell>cd /var/www/extsuite/

shell>mv extmail-1.2/ extmail

shell>cp extsuite/extmail/webmail.cf.default webmail.cf

shell>chown -R vmail:vmail /var/www/extsuite/extmail/

shell>chmow +x R /var/www/extsuite/extmail/cgi

shell>cp nginx.conf nginx.conf-2015-03-26

shell>vi 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;

修改NGINX以及php-fpm所屬用戶及組爲vmail,並修改相應文件屬主,php-fpm配置文件www.conf,否則NGINX無法啓動

shell>find / -gid 498 -exec chown :vmail {} \; #將所有屬組爲NGINX的文件的屬組修改爲vmail

shell>find / -uid 498 -exec chown vmail {} \; #將所有屬主爲NGINX的文件的屬主修改爲vmail

shell>cd conf.d/

shell>vi extmail.conf

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 fastcgi.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 fastcgi.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;

       }

   location ~ .*\.(php|php5)?$

    {      

      #fastcgi_pass  unix:/tmp/php-cgi.sock;

      fastcgi_pass  127.0.0.1:12009;

      fastcgi_index index.cgi;

      include fastcgi.conf;

    }

    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$

    {

expires      30d;

    }

    location ~ .*\.(js|css)?$

    {

expires      1h;

    }   

}


shell>vi /var/www/extsuite/extmail/dispatch-init

   MAXFORK=20

   MAXREQS=500

   TIMEOUT=300

   PORT=12009  #端口號與extmail.conf文件保持一致,

   SU_UID=vmail

   SU_GID=vmail

   

shell>tar -zxvf extman-1.1.tar.gz -C /var/www/extsuite

shell>mv extman-1.1/ extman

shell>chown -R vmail:vmail /var/www/extsuite/extman/

shell>mkdir -pv /tmp/extman

shell>chown -R vmail:vmail /tmp/extman/

shell>cd /var/www/extsuite/extman/docs/

shell>cp init.sql init.sql.back

shell>vi init.sql

更改init.sql中extmail.org的名稱爲自已域名


shell>vi extmail.sql

/*

 ExtMail - OSS

  License: GPL v2



 This is the MySQL database structure for ExtMail System, derive from

 Postfixadmin ( http://high5.net/howto/ ) project, and modify to meet

 our need, it is compatible with PostfixAdmin MySQL structure and have

 some extmail specific attributes and structure


 ExtMail have an alternative solution on openLDAP, please check the

 extmail.schema (V3) for detail.


 You can create the database from the shell with:


 mysql -u root [-p] < extmail.sql

*/


/*

 Initialize mysql

*/


USE mysql;

/* readonly user & password */

/* clean user if exists */

delete FROM user where User in ('extmail','webman');

delete FROM db where User in ('extmail','webman');


INSERT INTO user (Host, User, Password) VALUES ('localhost','extmail',password('extmail'));

INSERT INTO db (Host, Db, User, Select_priv) VALUES ('localhost','extmail','extmail','Y');


/* extman read/write user & password */

INSERT INTO user (Host, User, Password) VALUES ('localhost','webman',password('webman'));

INSERT INTO db (Host, Db, User, Select_priv, Insert_priv, Update_priv, Delete_priv) VALUES ('localhost', 'extmail', 'webman', 'Y', 'Y', 'Y', 'Y');

FLUSH PRIVILEGES;


/* readonly user */

GRANT USAGE ON extmail.* TO extmail@localhost;

GRANT SELECT, UPDATE ON extmail.* TO extmail@localhost;


/* read/write user */

GRANT USAGE ON extmail.* TO webman@localhost;

GRANT SELECT, INSERT, DELETE, UPDATE ON extmail.* TO webman@localhost;

CREATE DATABASE extmail;

USE extmail;


/* Table structure for table manager */

CREATE TABLE manager (

 username varchar(255) NOT NULL default '',

 password varchar(255) NOT NULL default '',

 type varchar(64) NOT NULL default 'postmaster',

 uid varchar(255) NOT NULL default '',

 name varchar(255) NOT NULL default '',

 question text NOT NULL default '',

 answer text NOT NULL default '',

 disablepwdchange smallint(1),

 createdate datetime NOT NULL default '0000-00-00 00:00:00',

 expiredate DATE NOT NULL default '0000-00-00',

 active tinyint(1) NOT NULL default '1',

 PRIMARY KEY (username)

) ENGINE=MyISAM COMMENT='Ext/Webman - Admin Accounts';

CREATE TABLE alias (

 address varchar(255) NOT NULL default '',

 goto text NOT NULL,

 domain varchar(255) NOT NULL default '',

 createdate datetime NOT NULL default '0000-00-00 00:00:00',

 active tinyint(1) NOT NULL default '1',

 PRIMARY KEY (address)

) ENGINE=MyISAM COMMENT='ExtMail - Virtual Aliases';

CREATE TABLE domain (

 domain varchar(255) NOT NULL default '',

 description varchar(255) NOT NULL default '',

 hashdirpath varchar(255) NOT NULL default '',

 maxalias int(10) NOT NULL default '0',

 maxusers int(10) NOT NULL default '0',

 maxquota varchar(16) NOT NULL default '0',

 maxnetdiskquota varchar(16) NOT NULL default '0',

 transport varchar(255) default NULL,

 can_signup tinyint(1) NOT NULL default '0',

 default_quota varchar(255) default NULL,

 default_netdiskquota varchar(255) default NULL,

 default_expire varchar(12) default NULL,

 disablesmtpd smallint(1),

 disablesmtp smallint(1),

 disablewebmail smallint(1),

 disablenetdisk smallint(1),

 disableimap smallint(1),

 disablepop3 smallint(1),

 createdate datetime NOT NULL default '0000-00-00 00:00:00',

 expiredate DATE NOT NULL default '0000-00-00',

 active tinyint(1) NOT NULL default '1',

 PRIMARY KEY (domain)

) ENGINE=MyISAM COMMENT='ExtMail - Virtual Domains';

CREATE TABLE domain_manager (

 username varchar(255) NOT NULL default '',

 domain varchar(255) NOT NULL default '',

 createdate datetime NOT NULL default '0000-00-00 00:00:00',

 active tinyint(1) NOT NULL default '1',

 KEY username (username)

) ENGINE=MyISAM COMMENT='Ext/Webman - Domain Admins';

CREATE TABLE mailbox (

 username varchar(255) NOT NULL default '',

 uid varchar(255) NOT NULL default '',

 password varchar(255) NOT NULL default '',

 clearpwd varchar(128) NOT NULL default '',

 name varchar(255) NOT NULL default '',

 mailhost varchar(255) NOT NULL default '',

 maildir varchar(255) NOT NULL default '',

 homedir varchar(255) NOT NULL default '',

 quota varchar(16) NOT NULL default '0',

 netdiskquota varchar(16) NOT NULL default '0',

 domain varchar(255) NOT NULL default '',

 uidnumber int(6) NOT NULL default '1000',

 gidnumber int(6) NOT NULL default '1000',

 createdate datetime NOT NULL default '0000-00-00 00:00:00',

 expiredate DATE NOT NULL default '0000-00-00',

 active smallint(1) NOT NULL default '1',

 disablepwdchange smallint(1),

 disablesmtpd smallint(1),

 disablesmtp smallint(1),

 disablewebmail smallint(1),

 disablenetdisk smallint(1),

 disableimap smallint(1),

 disablepop3 smallint(1),

 question text NOT NULL default '',

 answer text NOT NULL default '',

 PRIMARY KEY (username)

) ENGINE=MyISAM COMMENT='ExtMail - Virtual Mailboxes';


shell>mysql -u root -p <extmail.sql 

shell>mysql -u root -p <init.sql

shell>vi extmail/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_AUTHLIB_SOCKET = /usr/local/courier-authlib/var/spool/authdaemon/socket


shell>cd ../../extman/

shell>cp webman.cf.default webman.cf

shell>vi webman.cf

SYS_MAILDIR_BASE = /home/domains 右邊改爲/var/mailbox

SYS_DEFAULT_UID = 1001

SYS_DEFAULT_GID = 1001

SYS_CAPTCHA_ON = 0          //關閉圖形驗證碼


shell>/var/www/extsuite/extmail/dispatch-init start

shell>service nginx restart


配置postfix

shell> vi /etc/postfix/master.cf

maildrop  unix  -       n       n       -       -       pipe

  flags=DRhu user=vmail argv=/usr/local/bin/maildrop -d ${recipient}


shell> vi /etc/postfix/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 = njjnyy.cn

mydomain = njjnyy.cn

myorigin = $mydomain

inet_interfaces = all

#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain

mydestination =

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

 ############################CYRUS-SASL########################

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 = $mydomain

smtpd_sasl_security_options = noanonymous

#smtpd_sasl_application_name = smtpd

smtpd_banner = Welcome to our $myhostname ESMTP,Warning: Version not Available!

#############################SASL-END##############################

#############################Virtual Mailbox Settings################

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_domains=

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

#################################Mailbox END###########################

#################################Quota Settings########################

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

################################Quota END############################

################################Amavis Start##########################

content_filter=amavisfeed:[127.0.0.1]:10024

max_use=10

################################Amavis END###########################


測試郵件賬號

shell>/usr/local/courier-authlib/sbin/authtest -s smtp [email protected] l123456

正常顯示如下:

Authentication succeeded.

Authenticated: [email protected]  (uid 1001, gid 1001)

Home Directory: /var/mailbox/njjnyy.cn/lxb

Maildir: /var/mailbox/njjnyy.cn/lxb/Maildir/

Quota: 5242880S

Encrypted Password: $1$Ynp2/b/r$5DHAdX18fsbJMR98CU.1o/

Cleartext Password: a123456


安裝webmail圖形化日誌

shell>yum install rrdtool

shell>yum install rrdtool-perl

shell>yum install perl-Time-HiRes

shell>cd /usr/local/src/

shell>tar -zxvf File-Tail-1.0.tar.gz

shell>cd  File-Tail-1.0

shell>perl Makefile.PL

shell>make && make install

shell>cp -r /var/www/extsuite/extman/addon/mailgraph_ext /usr/local/

shell>/var/www/extsuite/extman/daemon/cmdserver -d

shell>/usr/local/mailgraph_ext/mailgraph-init start

shell>echo "/var/www/extsuite/extman/daemon/cmdserver -d" >>/etc/rc.local

shell>echo "/usr/local/mailgraph_ext/mailgraph-init start">>/etc/rc.local


extmail登錄界面修改

1 修改文件:/var/www/extsuite/extmail/html/default/index.html

設定默認域名

<TD><INPUT TYPE="text" class="input_n" NAME="domain" value="njjnyy.cn"></TD>

其中的domain和example.com隨自己實際情況進行更改。

POP3和SMTP設置信息提示   

POP3 <b>:</b>& nbsp;& nbsp;pop3.yourdomain.com<br />

SMTP <b>:</b>& nbsp;& nbsp;smtp.yourdomain.com<br />

技術支持和自願捐助連接,用<!-- -->註釋掉。

<div class=donate> <a href="http://www.extmail.org/support/<%LANG%>/index.html" target="_blank"> <b><%support_link%></b></a> | <img style="vertical-align: middle" src="/extmail/images/donate.png"> <a

2 修改文件:/var/www/extsuite/extmail/webmail.cf

去除免費註冊

修改位置:SYS_SHOW_SIGNUP = 1

修改結果:SYS_SHOW_SIGNUP = 0

去掉網絡磁盤功能

修改位置:SYS_NETDISK_ON = 1

修改結果:SYS_NETDISK_ON = 0

3 更換logo標誌

修改文件:/var/www/extsuite/extmail/html/default/images/logo.gif

修改內容:替換成需要的Logo圖片文件

4 修改文件:/var/www/extsuite/extmail/lang/zh_CN

修改位置:

%lang_login = (

meta_title => '歡迎使用ExtMail'


修改位置:

%lang_login = (

intro2 => '<b>快速而可靠</b><br />引入索引緩存(Cache)技術和高效核心,WebMail操作疾步如飛',

intro3 => '<b>多語言同屏讀寫</b><br />全面支持UTF8,實現同屏讀寫多國語言,真正做到國際郵、無亂碼',

intro4 => '<b>真正模板化設計</b><br />MVC設計+高速模板引擎,實現了內容數據完全分離,輕鬆修改模板',

intro5 => '<b>高性能I/O</b><br />;輕鬆應付>1GB郵箱/200M附件,遠強於流行的各式php webmail',


修改位置:

%lang_login = (

wsplash => '快速可靠, 高性能I/O

開源MAIL開足馬力邁進中...',


修改位置:

%lang_login = (

welcome_index => '歡迎使用ExtMail!'

5 修改文件:/var/www/extsuite/extmail/html/default/TOP_BAN.html

註釋掉

href="http://www.extmail.org/support/<%LANG%>/about.html"><%about%></a> | <a target=_blank href="http://www.extmail.org/support/<%LANG%>/help.html"><%help%></a></span>

6修改文件:/var/www/extsuite/extmail/html/default/BOTTOM.html

<div id="Bcr">Powered by <%VERSION%> 2006 ExtMail.Org Runtime: <%TIME%><br>

<%extmail_whatis%></div>

上面內容可以根據頁面底部的顯示信息對比修改。

7 修改文件:/var/www/extsuite/extmail/html/default/welcome.html

去掉項目新聞 註釋掉下面內容

<div style="padding-left: 5px;padding-right:5px">

                <div class="panelout" id="etnews_div">

                <div class="paneltit">&nbsp;ExtMail Project News</div>

                <div class="panelin" id="etnews_container">

                </div>

                </div>

                <script type="text/javascript">

                        etnews_init();

                </script>

                </div>

8 更換原天氣預報代碼

更換掉原來的這段代碼

<TD  width=230px valign=top style="">

                <div class="panelout" id="coolweather_div">

                        <div class="paneltit">&nbsp;<%weatherinfo%></div>

                        <div class="panelin" id="coolweather_container">

                        </div>

                        <script type="text/javascript">

                                coolweather_iconspath = '/extmail/plugins/coolweather/icons/';

                                coolweather_init();

                        </script>

                </div>

        </TD>

        <TD width=10px></TD>

新的代碼爲

<TD  width=230px valign=top style="">

        <iframe src="http://www.thinkpage.cn/weather/weather.aspx?c=BU5CI&l=&p=CMA&a=1&u=C&s=1&m=1&x=1&d=3&fc=&bgc=&bc=" frameborder="0" scrolling="no" width="200" height="260" allowTransparency="true">

        </iframe>

        </TD>

        <TD width=10px></TD>


安裝CLAMAV殺毒軟件

shell>adduser -s /bin/false -c "Amavis User" -d /var/amavis amavis

shell>useradd -s/bin/false -d /dev/null clamav

shell>cd /usr/local/src/

shell>tar zxvf clamav-0.98.6.tar.gz

shell>./configure --prefix=/usr/local/clamav --with-dbdir=/usr/local/share/clamav

shell>make

shell>make install

shell>cp clamd.conf.sample clamd.conf

shell>vi clamd.conf

LogFile /var/log/clamav/clamd.log

LogTime yes

LogFacility LOG_MAIL

LogSyslog yes

LogVerbose yes

PidFile /var/run/clamd.pid

DatabaseDirectory /usr/local/share/clamav

LocalSocket /tmp/clamd.socket

StreamMaxLength 100M

User amavis

ScanMail yes

ScanArchive yes


shell>sed -e  '/^#/d' -e '/^$/d' clamd.conf #查看配置文件

shell>cp freshclam.conf.sample freshclam.conf

shell>vi freshclam.conf

DatabaseDirectory /usr/local/share/clamav

UpdateLogFile /var/log/clamav/freshclam.log

LogVerbose yes

LogSyslog yes

LogTime yes

PidFile /var/run/freshclam.pid

DatabaseOwner amavis

DatabaseMirror db.CN.clamav.net

DatabaseMirror database.clamav.net

Checks 12


shell>mkdir /usr/local/share/clamav

shell>mkdir /var/log/clamav

shell>chmod -R 744 /var/log/clamav

shell>chown -R amavis:amavis /var/log/clamav

shell>chown -R amavis.amavis /usr/local/share/clamav

shell>vi /etc/init.d/clamd

#! /bin/bash

#

# crond Start/Stop the clam antivirus daemon.

#

# chkconfig: 2345 90 60

# description: clamdis a standard UNIX program that scans for Viruses.

# processname: clamd

# config: /usr/local/clamav/etc/clamd.conf

# pidfile: /var/run/clamd.pid

# Source function library.

. /etc/init.d/functions

RETVAL=0

# See how we were called.

prog="clamd"

progdir="/usr/clamav/local/sbin"

# Source configuration

if [ -f /etc/sysconfig/$prog ] ; then

 . /etc/sysconfig/$prog

fi

start() {

 echo -n $"Starting $prog: "

 daemon $progdir/$prog

 RETVAL=$?

 echo

 [ $RETVAL -eq 0 ] && touch /var/run/clamd.pid

 return $RETVAL

}

stop() {

 echo -n $"Stopping $prog: "

 killproc $prog

 RETVAL=$?

 echo

 [ $RETVAL -eq 0 ] && rm -f /var/run/clamd.pid

 return $RETVAL

}

rhstatus() {

 status clamd

}

restart() {

 stop

 start

}

reload() {

 echo -n $"Reloading clam daemon configuration: "

 killproc clamd -HUP

 retval=$?

 echo

 return $RETVAL

}

case "$1" in

 start)

 start

 ;;

 stop)

 stop

 ;;

 restart)

 restart

 ;;

 reload)

 reload

 ;;

 status)

 rhstatus

 ;;

 condrestart)

 [ -f /var/lock/subsys/clamd ] && restart || :

 ;;

 *)

 echo $"Usage: $0 {start|stop|status|reload|restart|condrestart}"

 exit 1

esac

exit 0

shell>chkconfig --add clamd 

shell>chkconfig clamd on

shell>service clamd start

shell>/usr/local/clamav/bin/freshclam


安裝amavisd-new amavisd-new是一個高性能、可靠的用於連接郵件傳輸代理和內容檢查器之間的接口,例如郵件的病毒掃描、垃圾郵件過濾等等

查看已經安裝的perl模塊

shell>perldoc -t perllocal | grep "Module"

shell>yum install perl-YAML.noarch

shell>cd /usr/local/src

shell>tar zxvf Mail-SPF-v2.9.0.tar.gz

shell>cd Mail-SPF-v2.9.0

shell>perl Makefile.PL

shell>make && make install

shell>perl -MCPAN -e shell ## 在安裝前確定你的系統語言不是UTF-8

    cpan> install Archive::Tar

    cpan> install Archive::Zip

    cpan> install Compress::Zlib

    cpan> install Convert::TNEF

    cpan> install Convert::UUlib

cpan> install Convert::BinHex

    cpan> install MIME::Base64

    cpan> install MIME::Parser

cpan> install MIME::Tools

    cpan> install Mail::Internet

    cpan> install Net::Server

cpan> install Net::LibIDN

    cpan> install Net::SMTP

    cpan> install Digest::MD5

    cpan> install IO::Stringy

    cpan> install Time::HiRes

    cpan> install Unix::Syslog

    cpan> install BerkeleyDB

cpan> install Crypt::OpenSSL::RSA

    cpan> install Digest::SHA1

    cpan> install DBI

    cpan> install DB_File

    cpan> install Net::DNS

cpan> install Mail::DKIM::Verifier

cpan> install Mail::SpamAssassin

    cpan> install IP::Country

cpan> install URI::_idna

cpan> install Net::IDN::Encode

cpan> install Net::Ident

cpan> install IO::Socket::INET6

    cpan> install IO::Socket::SSL

cpan> install NetAddr::IP

cpan> install Net::DNS::Resolver::Programmable

cpan> install installed: Geo::IP

cpan> install Razor2::Client::Agent

cpan> install IO::Socket::IP

cpan> install Encode::Detect

cpan> install Net::Patricia

cpan> install LWP::UserAgent

cpan> install Mail::SPF::Query

cpan> install HTML::Parser

cpan> exit

shell>vi amavisd.sh

#!/bin/bash

tar Jxvf amavisd-new-2.10.1.tar.xz  && cd amavisd*

mkdir -p /var/amavis/tmp /var/amavis/var /var/amavis/db /var/amavis/home

chown -R amavis:amavis /var/amavis

chmod -R 750 /var/amavis

cp amavisd /usr/local/sbin/

chown root /usr/local/sbin/amavisd

chmod 755 /usr/local/sbin/amavisd

cp amavisd.conf /etc/

chown root /etc/amavisd.conf

chmod 644 /etc/amavisd.conf

mkdir /var/virusmails

chown amavis:amavis /var/virusmails

chmod 750 /var/virusmails

cp amavisd_init.sh /etc/init.d/amavisd

chmod 744 /etc/init.d/amavisd

chkconfig --add amavisd

chkconfig amavisd on


shell>./amavisd.sh

vi /etc/amavisd.conf

$max_servers=8;  

$daemon_user = 'amavis'; 

$daemon_group = 'amavis'; 

$mydomain = 'njjnyy.cn'; 

$db_home = "$MYHOME/db"; 

$inet_socket_port = 10024; 

$sa_tag_level_deflt = 5.0;  

$sa_tag2_level_deflt = 6.2;  

$sa_kill_level_deflt = $sa_tag2_level_deflt; 

$virus_admin = "virusalert@$mydomain"; 

$sa_spam_subject_tag = '***SPAM*** '; 

$forward_method = 'smtp:127.0.0.1:10025'; 

$notify_method = $forward_method;

$final_virus_destiny = D_DISCARD; 

$final_banned_destiny = D_DISCARD; 

$final_spam_destiny = D_DISCARD; 

['ClamAV-clamd',

   \&ask_daemon, ["CONTSCAN {}\n", "/amd.socketmp/clamd.socket"],

   qr/\bOK$/m, qr/\bFOUND$/m,

   qr/^.*?: (?!Infected Archive)(.*) FOUND$/m ],





自動更新spamassassin clamav

shell>rpm -ivh --nodeps cronie

shell>crontab -e

0 0 * * * /usr/local/bin/sa-update -D --nogpg

0 4 * * * /usr/local/clamav/bin/freshclam  --quiet -l /var/log/clamav/freshclam.log







發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章