• Home
  • Uncategorized
  • How to compile and install the latest clamav antivirus on your server

How to compile and install the latest clamav antivirus on your server

Download the latest production clamav:

wget http://downloads.sourceforge.net/clamav/clamav-0.98.3.tar.gz
tar xf clamav-0.98.3.tar.gz
cd clamav-0.98.3
apt-get install libxml2 libxml2-dev libbz2-dev libzip2 libzip-dev
./configure
make && make install

If you get the error:
“#clamd
clamd: error while loading shared libraries: libclamav.so.6: cannot open shared object file: No such file or directory”

Solution:
Run ldconfig:

#ldconfig

Now,

cp ./etc/clamd.conf.sample /usr/local/etc/clamd.conf
cp ./etc/freshclam.conf.sample /usr/local/etc/freshclam.conf
emacs /usr/local/etc/clamd.conf
emacs /usr/local/etc/freshclam.conf

Create user and group for clamav, and then create log file and clamav directory, setting appropriate permissions:

groupadd clamav
useradd -g clamav -s /bin/false -c "Clam Antivirus" clamav
touch /var/log/freshclam.log
mkdir /var/lib/clamav
touch /var/run/freshclam.pid
chown clamav.clamav /var/log/freshclam.log
chown clamav.clamav /var/lib/clamav
chown clamav.clamav /var/run/freshclam.pid

Now update the database by running freshclam as daemon:

#sudofreshclam -d

If that doesnt work:

#sudo freshclam -v

Read the documentation at http://www.clamav.net/doc/latest.bak/clamdoc.pdf

Comment out the line “Example” from both example conf files.
/usr/local/etc/clamd.conf:

LogTime
PidFile /var/run/clamav/clamd.pid
TemporaryDirectory /var/tmp
DatabaseDirectory /var/clamav
LocalSocket /var/run/clamav/clamd.sock
FixStaleSocket
MaxConnectionQueueLength 30
ReadTimeout 180
SelfCheck 3600
User amavis
AllowSupplementaryGroups
ScanPE
DetectBrokenExecutables
ScanOLE2
ScanMail
ScanHTML
ScanArchive
ArchiveMaxFileSize 10M
ArchiveMaxRecursion 5
ArchiveMaxFiles 1000
ArchiveMaxCompressionRatio 300
ArchiveBlockEncrypted
ArchiveBlockMax

/usr/local/etc/freshclam.conf:

DatabaseDirectory /var/lib/clamav
UpdateLogFile /var/log/freshclam.log
LogFileMaxSize 2M
LogTime yes
LogRotate yes
PidFile /var/run/freshclam.pid
DatabaseMirror database.clamav.net
ScriptedUpdates yes
Checks 24
ConnectTimeout 60
ReceiveTimeout 60
Bytecode yes