Howto: Installing ClamAV from source

This howto shows how to install ClamAV from source on Ubuntu.

First we need to install dependent packages:

apt-get install libxml2-dev libssl-dev libpcre3-dev libbz2-dev

Now we can clone the github repository:

cd /usr/local/src/
git clone git://github.com/vrtadmin/clamav-devel

We need to prepare the users and some folders:

groupadd clamav
useradd -g clamav clamav

mkdir /var/clamav
chown clamav:root /var/clamav

mkdir /var/log/clamav/
chown clamav:root /var/log/clamav/

mkdir /usr/local/share/clamav
chown clamav:clamav /usr/local/share/clamav

touch /var/log/freshclam.log
chown clamav:clamav /var/log/freshclam.log

mkdir /var/lib/clamav
chown clamav:clamav -R /var/lib/clamav

touch /var/log/clamd.log
chown clamav:clamav /var/log/clamd.log

touch /var/run/clamd.pid
chown clamav:clamav /var/run/clamd.pid

Ready to build:

cd clamav-devel
./configure -with-dbdir=/usr/local/share/clamav/ -- libdir=/usr/local/lib/
make && make install

ldconfig

Configure:

cd /usr/local/etc/
mv clamd.conf.sample clamd.conf
vim clamd.conf
mv freshclam.conf.sample freshclam.conf
vim freshclam.conf

Update the virus database:

freshclam

Cron automatic hourly updates:

vi /etc/cron.hourly/freshclam 

/usr/local/bin/freshclam --quiet -l         /var/log/clamav/freshclam.log 

chmod 0755 /etc/cron.hourly/freshclam 

Start Clam deamon:

clamd &