Clamav安装配置

安装clamav

Shell> groupadd –g 1006 clamav

Shell> useradd –g 1006 –u 1006 –s /bin/false –d /dev/null –c “Clamav Install User” clamav

 

Shell> tar zxvf clamav-0.98.4-r1.tar.gz

Shell> cd clamav-0.98.4-r1

Shell> ./configure –prefix=/data/sw/clamav –with-dbdir=/data/sw/clamav/db

Shell> make && make install

 

Shell> mkdir –p /data/sw/clamav/run /data/sw/clamav/db /data/sw/clamav/logs

Shell> groupadd –g 1007 amavis

Shell> useradd –g 1007 –u 1007 –s /bin/flase –d /dev/null –c “Amavis User” amavis

Shell> chown –R amavis:amavis /data/sw/clamav/run /data/sw/clamav/db /data/sw/clamav/logs

Shell> chmod –R 700 /data/sw/clamav/run

 

Shell> cp /data/sw/clamav/etc/clamd.conf.sample /data/sw/clamav/etc/clamd.conf

Shell> cp /data/sw/clamav/etc/freshclam.conf.sample /data/sw/clamav/etc/freshclam.conf

 

配置clamav

Shell> cd /data/sw/clamav

Shell> vi etc/clamd.conf

注销Example,并修改配置如下

postfix垃圾邮件处理_第1张图片

Shell> vi etc/freshclam.conf

注销Example并修改配置如下

clip_p_w_picpath004

升级病毒库

Shell> cd /data/sw/clamav

Shell> bin/freshclam

启动clamav

Shell> /data/sw/clamav/sbin/clamd

病毒库自动更新

Shell> echo “0 4 * * * root /data/sw/clamav/bin/freshclam --quiet --log=/data/sw/clamav/logs/freshclam.conf” >> /etc/crontab

Spamassassin的安装

Shell> tar zxvf Mail-SpamAssassin-3.4.0.tar.gz

Shell> cd Mail-SpamAssassin

Shell> perl Markfile.PL

postfix垃圾邮件处理_第2张图片

Fetch的安装

 

Shell> tar zxvf http_fetcher-1.1.0.tar.gz

Shell> cd http_fetcher-1.1.0

Shell> ./configure

Shell> vi src/http_fetcher.c

注释掉781

clip_p_w_picpath007

Shell> make && make install

 

Shell> tar zxvf fetch-1.0.tar.gz

Shell> cd fetch-1.0

Shell> ./configure

Shell> make && make install

 

Curl安装

Shell> tar zxvf fetch-7.37.0.tar.gz

Shell> cd fetch-7.37.0

Shell> ./configure

Shell> make && make install

Gnupg安装

Shell> tar xvf libassuan-2.1.1.tar.bz2

Shell> cd libassuan-2.1.1

Shell> ./configure

Shell> make && make install

 

Shell> tar xvf libgpg-error-1.13.tar.bz2

Shell> cd libgpg-error-1.13

Shell> ./configure

Shell> make && make install

 

Shell> tar xvf libksba-1.3.0.tar.bz2

Shell> cd libksba-1.3.0

Shell> ./configure

Shell> make && make install

 

Shell> tar zxvf pth-2.07.tar.gz

Shell> cd pth-2.07

Shell> ./configure

Shell> make && make install

 

Shell> ldconfig –v

Shell> tar zxvf gnupg-1.4.16.tar.bz2

Shell> cd gnupg-1.4.16

Shell> ./configure

Shell> make && make install

Razor2安装

Geo-IP的安装

Shell> tar zxvf Geo-IP-1.4.3.tar.gz

Shell> cd Geo-IP-1.4.3

Shell> perl Mailfile.PL PP=1

Shell> make && make install

 

perl模块安装

Shell> perl –MCPAN –e shell

Cpan> install HTML::Parser

Cpan> install Net::DNS

Cpan> install Net::DNS::Resolver::Programmable

Cpan> install NetAddr::IP

Cpan> install Digest::SHA1

Cpan> install IO::Socket::IP

Cpan> install IO::Socket::INET6

Cpan> install IO::Socket::SSL

Cpan> install Mail::DKIM

Cpan> install LWP::UserAgent

Cpan> install HTTP::Date

Cpan> install Encode::Detect

Cpan> install Net::Patricia

Cpan> install Time::HiRes

Cpan> install Archive::Tar

Cpan> install MIME::Base64

Cpan> install Mail::SPF

Cpan> install DBI

Cpan> install Net::LDAP

Cpan> install ZeroMQ

Cpan> install SpamAssassin

Cpan> install Razor2::Client::Agent

Cpan> install XML::LibXML::Iterator

更多模块参考SpamAssassin安装目录INSTALL文件

 

Shell> perl Makefile.PL

Shell> make && make install

 

启动

Shell> sa-update –no-gnupg

Shell> spamassassin &

 

Amavisd安装配置

安装amavisd

Shell> tar xvf amavisd-new-2.9.0.tar.xz

Shell> cd amavisd-new-2.9.0

Amavisd和Spamassassin安装需要很多perl module,安装之间先看下INSTALL文件,源码安装太麻烦,如果有联网建议CPAN安装

INSTALL列出先决条件如下:

postfix垃圾邮件处理_第3张图片

Perl 模块如下

clip_p_w_picpath011

邮件病毒扫描需求(已经安装)

clip_p_w_picpath013

扩展程序(暂时不安装)

postfix垃圾邮件处理_第4张图片

第三方工具(暂时不安装)

postfix垃圾邮件处理_第5张图片

Shell> perl –MCAPN –e shell

Cpan> install Archive::Zip

Cpan> install Compress::Zlib

Cpan> install Compress::Raw::Zlib

Cpan> install MIME::Base64

Cpan> install MIME::Parser

Cpan> install Mail::Internet

Cpan> install Net::Server

Cpan> install Digest::MD5

Cpan> install Time::HiRes

Cpan> install Unix::Syslog

Cpan> install Mail::DKIM

Cpan> install IO::Stringy

Cpan> install Convert::BinHex

Cpan> install BerkeleyDB

Cpan> install Unix::Getrusage

cpan> install Image::Info

 

amavisd配置

shell> vi /etc/amavisd.conf

$daemon_user = 'amavis';

$daemon_group = 'amavis';

$mydomain = 'zhengwing.org';

$MYHOME = '/var/amavis';

$TEMPBASE = "$MYHOME/tmp";.

$QUARANTINEDIR = '/var/amavis/var/virusmails';

$db_home = "$MYHOME/db";

$helpers_home = "$MYHOME/home";

$lock_file = "$MYHOME/var/amavisd.lock";

$pid_file = "$MYHOME/var/amavisd.pid";

$unix_socketname = "$MYHOME/var/amavisd.sock";

$myhostname = 'mail.zhengwing.org';

##以上是amavisd.conf基本配置

##以下是amavisd.conf关于clamav配置

['ClamAV-clamd-stream',

\&ask_daemon, ["*", 'clamd:/data/sw/clamav/run/clamd.sock'],

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

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

 

Postfix支持amavisd

Shell> vi /etc/postfix/main.cf

clip_p_w_picpath018

Shell> vi /etc/postfix/master.cf

postfix垃圾邮件处理_第6张图片

Shell> postfix reload

调试

Shell> /usr/local/sbin/amavisd –u amavis debug

如果有问题,参照调试日志修改

启动

Shell> /usr/local/sbin/amavisd –u amavis &