linux下ClamAV使用
第一步:Clamav下载
http://www.clamav.net/downloads
#yuminstall wget –y
第二步:创建clamav用户和组
groupaddclamav (创建clamav组)
useradd-g clamav clamav(创建clamav用户并加入clamav组)
<ignore_js_op>
第三步:编译安装
tar xfclamav-0.99.2.tar.gz
cdclamav-0.99.2
<ignore_js_op>
安装依赖包
yuminstall gcc openssl openssl-devel -y
<ignore_js_op>
./configure--prefix=/usr/local/clamav
make&&make install
第四步:配置
mkdir /usr/local/clamav/logs (日志存放目录)
touch /usr/local/clamav/logs/clamd.log
touch /usr/local/clamav/logs/freshclam.log
mkdir /usr/local/clamav/updata (clanav 病毒库目录)
chown -R root.clamav /usr/local/clamav/
chown -R clamav.clamav /usr/local/clamav/updata/
chown clamav.clamav /usr/local/clamav/logs/clamd.log
chown clamav.clamav /usr/local/clamav/logs/freshclam.log
cd /usr/local/clamav/etc
cp clamd.conf.sample clamd.conf
cp freshclam.conf.sample freshclam.conf
vim clamd.conf
#Example 注释掉这一行.
LogFile /usr/local/clamav/logs/clamd.log
PidFile /usr/local/clamav/updata/clamd.pid
DatabaseDirectory /usr/local/clamav/updata
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vim freshclam.conf
#Example 注释掉这一行.
DatabaseDirectory /usr/local/clamav/updata
UpdateLogFile /usr/local/clamav/logs/freshclam.log
PidFile /usr/local/clamav/updata/freshclam.pid
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
第五步:升级病毒库
/usr/local/clamav/bin/freshclam
这个过程很久,大概半个小时。可以开启screen来进行。
/usr/local/clamav/bin/clamscan--remove (查杀当前目录并删除感染的文件)
注意:确保网络正常
第六步:计划任务
实际生产环境应用
一般使用计划任务,让服务器每天晚上定时跟新和定时杀毒。保存杀毒日志,我的crontab文件如下
1 3 * ** /usr/local/clamav/bin/freshclam
30 3 * * * /usr/local/clamav/bin/clamscan --infected -r / --remove -l /var/log/clamscan.log