How To Install/Compile ClamAV In CentOS 6

by admin on September 8, 2014

Clam AntiVirus (ClamAV) is a free and open-source, cross-platform antivirus software tool-kit able to detect many types of malicious software, including viruses. It’s easy to use and best for Linux based Web & Mail server. In this article, I will show you through the step by step installation of ClamAV on CentOS 6.x from source.

The first, You need to download ClamAV latest version at http://www.clamav.net. Login as root and type the following command

# wget http://downloads.sourceforge.net/project/clamav/clamav/0.98.4/clamav-0.98.4.tar.gz?r=http%3A%2F%2Fwww.clamav.net%2Fdownload.html&ts=1410062157&use_mirror=softlayer-sng -O clamav-0.98.4.tar.gz

The second, extracting clamav-0.98.4.tar.gz package

# tar zxvf clamav-0.98.4.tar.gz
# cd clamav-0.98.4

Installing ClamAV

Type the following command to Compile ClamAV from source

# ./configure --prefix=/usr/local --sysconfdir=/etc --with-xml=/usr/local --with-zlib=/usr
# make
# make install

Configuring ClamAV

Creating user for clamav, enter

useradd -s /sbin/nologin -d /dev/null clamav

Creating database folder of clamav, enter

# mkdir /usr/local/share/clamav
# chown clamav /usr/local/share/clamav
# chmod 700 /usr/local/share/clamav

Type these following commands to create ClamAV configuration files

mv /etc/freshclam.conf.sample /etc/freshclam.conf
mv /etc/clamd.conf.sample /etc/clamd.conf

Open and remove contains

# Comment or remove the line below.
Example

Updating ClamAV

# freshclam

Configuring daily scan

In this example, I will configure a cronjob to scan the /home/ directory every day. Creating a file called name scanav at /opt/, enter

# vi /opt/scanav

Add the following to the file above

#!/bin/bash

SCAN_DIR="/home"
SCAN_LOG="/var/log/clamav.log"

# Update CLAMAV
freshclam

# Scan AV
clamscan -i -r $SCAN_DIR >> $SCAN_LOG

Give our cron script executable permissions, enter

# chmod +x /opt/scanav

Configuring daily scan with crontab, type the following command

# crontab -e

Add the following

01 01 * * * /opt/scanav

Leave a Comment

Previous post:

Next post: