Installing ClamAV 0.93.3

来源:互联网 发布:淘宝上阿迪达斯是真的 编辑:程序博客网 时间:2024/05/16 09:51

Installing ClamAV 0.93.3 From The Sources (+ Sendmail Integration) On CentOS 5.2

原文作者: Ioan Ungureanu

原文地址:http://howtoforge.org/installing-clamav0.93.3-from-the-sources-plus-sendmail-integration-centos5.2
Email:server@ro-design.net

 

Note: This how-to refers to the installation and configuration of Clamav 0.93.3 (from sources) on a Linux server running CentOS 5.2 and sendmail.
We assume the fact you/u2019ve installed sendmail and sendmail-devel from the rpm packages of your distribution

If not just run the command:

 

1、yum install sendmail sendmail-devel(安装sendmail包)

The sendmail-devel package is not optional here because we need libmilter. If we don/u2019t install sendmail-devel we have to deal with error message libmilter not foud, so we avoid from start such a stop error.


Installing ClamAV-0.93.3 from sources

We need first to create the user and group:

2、groupadd clamav 创建clamav组
3、useradd -g clamav clamav        创建clamav用户

We will change the password for the user clamav; for security reasons, this is not really necessary but recommended, choose a complex password, you don't need to remember after install; as a security rule, assume in your /etc/passwd user clamav has /sbin/nologin as shell environment like below, where uid and gid are the user id and group id assigned for clamav user.

cat /etc/passwd |grep 'clamav'

clamav:x:uid:gid::/home/clamav:/sbin/nologin

passwd clamav

 

We create next working directories for daemon and storeplace for logs:

4、mkdir /var/clamav
5、chown clamav:root /var/clamav
6、mkdir /var/log/clamav/
7、chown clamav:root /var/log/clamav/
8、mkdir /usr/local/share/clamav
9、chown clamav:clamav /usr/local/share/clamav

 

Now download the ClamAV 0.93.3 sources from a mirror (we used heatnet as a mirror, if it is slow or not responding you can choose another mirror from):下载ClamAV 0.93.3 包

wget http://dl.sourceforge.net/sourceforge/clamav/clamav-0.93.3.tar.gz

or use a mirror like http://sourceforge.net/project/downloading.php?group_id=86638&use_mirror=osdn&filename=clamav-0.93.3.tar.gz&88361377&abmode=1.

 

10、tar xzvf clamav-0.93.3.tar.gz

11、cd clamav-0.93.3
12、./configure -disable-clamuko -enable-milter -with-dbdir=/usr/local/share/clamav(配置软件包,后面的参数都是可选)

 

Basically, on distributions Red Hat based, when trying to compile clamav we see an error from incompatibility with zlib. You have the choise to install both zlib and zlib-devel packages with

yum install zlib zlib-devel
If there are erros, like configure: error: The installed zlib version may contain a security bug. Please upgrade to 1.2.2 or later: http://www.zlib.net. You can omit this check with /u2013disable-zlib-vcheck but DO NOT REPORT any stability issues then!
 we write the command:

yum update zlib zlib-devel

The chance to get error still exist so it is safe to run:

12、./configure -disable-clamuko -enable-milter -with-dbdir=/usr/local/share/clamav -disable-zlib-vcheck

After we run, for both cases:

13、make(编译软件包)

14、make install(安装软件)

 

We need a file named clamav.conf. We edit it in /etc:(根据自己的需要,修改配置文件)

但是,一定记得把example这一行加个#以注释掉,后面的程序才可以跑

vi /etc/clamav.conf

Write the following lines:

#/etc/clamav.conf
LogTime
LogSyslog
LogFile /var/log/clam/clamd.log
PidFile /var/run/clam/clamd.pid
LocalSocket /var/run/clam/clamd.sock
FixStaleSocket
MaxThreads 50
ThreadTimeout 600
MaxDirectoryRecursion 15
FollowFileSymlinks
SelfCheck 600
User clamav
ScanMail
ScanArchive
ArchiveMaxFileSize 10M #file max size in Megabytes for archived scaned files.You can modify this to suit your purposes
ArchiveMaxRecursion 5
ArchiveMaxFiles 1000

Save and close the file.

 

 

Now tell your startup script to load the ClamAV daemon:

echo "/usr/local/sbin/clamd" >> /etc/rc.d/rc.local
echo "/usr/local/sbin/clamav-milter -l -o -q /var/milter/clmilter.sock">> /etc/rc.d/rc.local

cp /etc/clamav.conf /usr/local/etc/
touch /var/log/clam-update.log
chown clamav:clamav /var/log/clam-update.log
touch /tmp/clamd.log
chown clamav:root /tmp/clamd.log
mkdir /var/milter
chown clamav:root /var/milter/
cd /usr/local/etc/

We modify some configuration files [you can download/use those used by me] in the directory /etc:

cd /etc

wget ftp://ftp.ro-design.net/pub/clamd.conf
wget ftp://ftp.ro-design.net/pub/freshclam.conf
mkdir /var/lib/clamav
chown clamav:root /var/lib/clamav/
/usr/local/bin/freshclam -l /var/log/clam-update.log
cp /usr/local/sbin/clamd /etc/init.d/
/etc/init.d/clamd restart

 

In the file /etc/mail/sendmail.mc add the lines:

INPUT_MAIL_FILTER(`clmilter/u2019,`S=local:/var/milter/clmilter.sock, F=, T=S:4m;R:4m/u2019)

 

dnl define(`confINPUT_MAIL_FILTERS/u2019, `clmilter/u2019)

m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
/etc/init.d/sendmail restart
crontab -e

 

Add the lines below:

# we will update the database used by Clamav antivirus daily, twice
0 2,13 * * * /usr/local/bin/freshclam /u2013quiet -l /var/log/clam-update.log

Finally:

/etc/rc.d/rc.local

 

For any questions or troubles you can contact me at: server@ro-design.net