1 – Install EPEL 7
RHEL7:
# wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm
# rpm -Uvh epel-release*.rpm
CentOS 7:
# yum install epel-release
2 – Install and configure the ClamAV packages
# yum install clamav clamav-scanner-systemd
Create a symbolic link to the default file path and link it to the clamd@scan file (read comments for more information):
# ln -s /etc/clamd.d/scan.conf /etc/clamd.conf
Edit the configuration installed by the clamd-scanner package:
# vi /etc/clamd.d/scan.conf
Comment the example line:
#Example
Uncomment the LocalSocket config line to enable it:
LocalSocket /var/run/clamd.scan/clamd.sock
Save and quit the text editor.
3 – Turn on the SELinux boolean for antivirus
# setsebool -P antivirus_can_scan_system 1
4 – Start the service and enable it at boot
# systemctl start clamd@scan
# systemctl enable clamd@scan
5 – Install and configure the ClamAV updater
To automatically get the latest virus updates, you need to install the binary used for this task:
# yum install clamav-update
Edit the configuration file:
# vi /etc/freshclam.conf
Comment the example line:
#Example
Edit the second configuration file (in sysconfig):
# vi /etc/sysconfig/freshclam
Comment this line to allow you to use crontab (updates are disabled by default):
#FRESHCLAM_DELAY=disabled-warn
Save files and quit the text editor and run the command “freshclam” to update the virus database. If needed you can add a crontab to execute it regularly.
6 – Test your installation
# clamdscan –fdpass /var/log/*
Always use the –fdpass to give the correct permission to scan the files with clamdscan binary. In some case the first check mays fail after the installation, a simple reboot can solve this issue.