In this tutorial we’ll learn how to install ClamAV on CentOS 7. We will also install and configure its prerequisites. Clam AntiVirus is a totally free and open source toolkit that has been initially developed for Unix. The clam can detect viruses, malware, and many other malicious threats. This tool does is via the control line. But do not let that scare you off as numerous front-ends (GUI’s) can be found, such as the famous Clam Tk.
I recommend to use a minimal CentOS server setup as a basis for the tutorial, that can be a virtual or a root server image with an CentOS 7 minimal install from a web hosting company or you use our minimal server tutorial to install a server from scratch.
Install ClamAV on CentOS 7
Step 1. First, ensure your system is fully up-to-date by running the following:
yum -y update yum -y install epel-release
Step 2. Installing ClamAV antivirus.
Now run the following command to install ClamAV antivirus:
yum -y install clamav-server clamav-data clamav-update clamav-filesystem clamav clamav-scanner-systemd clamav-devel clamav-lib clamav-server-systemd
Step 3. Configuring ClamAV.
Before Clam configuration can be enabled, you need to remove Example string from the configuration file:
sed -i -e "s/^Example/#Example/" /etc/clamd.d/scan.conf
Open configuration file with your favorite text editor, in this example we will use nano:
Scroll to this line:
Change it to:
Next step, remove Example string from ClamAV’s freshclam update engine configuration file:
sed -i -e "s/^Example/#Example/" /etc/freshclam.conf
Run virus definition database update:
Start Clamd service and run in on boot:
systemctl start clamd@scan systemctl enable clamd@scan