Installing ClamAV 0.93.3 From The Sources (+ Sendmail Integration) On CentOS 5.2
Author: Ioan Ungureanu
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’ve installed sendmail and sendmail-devel from the rpm packages of your distribution
If not just run the command:
yum install sendmail sendmail-devel
The sendmail-devel package is not optional here because we need libmilter. If we don’t 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:
useradd -g 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'
We create next working directories for daemon and storeplace for logs:
chown clamav:root /var/clamav
chown clamav:root /var/log/clamav/
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):
tar xzvf clamav-0.93.3.tar.gz
./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 –disable-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:
./configure –disable-clamuko –enable-milter –with-dbdir=/usr/local/share/clamav –disable-zlib-vcheck
After we run, for both cases:
We need a file named clamav.conf. We edit it in /etc:
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/
chown clamav:clamav /var/log/clam-update.log
chown clamav:root /tmp/clamd.log
chown clamav:root /var/milter/
We modify some configuration files [you can download/use those used by me] in the directory /etc:
chown clamav:root /var/lib/clamav/
/usr/local/bin/freshclam -l /var/log/clam-update.log
cp /usr/local/sbin/clamd /etc/init.d/
In the file /etc/mail/sendmail.mc add the lines:
INPUT_MAIL_FILTER(`clmilter’,`S=local:/var/milter/clmilter.sock, F=, T=S:4m;R:4m’) dnl define(`confINPUT_MAIL_FILTERS’, `clmilter’) m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
Add the lines below:
# we will update the database used by Clamav antivirus daily, twice 0 2,13 * * * /usr/local/bin/freshclam –quiet -l /var/log/clam-update.log
For any questions or troubles you can contact me at: email@example.com