How to Install ClamAV on CentOS 7


ClamAV is free and open-source antivirus software, which can be used on multiple platforms. In this tutorial, we will overview ClamAV installation on CentOS 7.

What you’ll need

Before you begin this guide you’ll need the following:

  • SSH root access to the VPS

Step 1 — Installing ClamAV on CentOS 7

As Clam does not come with default CentOS software repos, we will have to add the additional repository by running yum:

Now, it’s time to install Clam on CentOS. Once again, just run the following command:

All is done, you have just installed antivirus software on your server.

Step 2 — Configuring SELinux

SELinux is a security measure aimed at protecting changes to some files. Additional configuration is required if you want to use ClamAV with enabled SELinux kernel module, otherwise Clam will not be able to read some portion of your files. Just execute following commands:

To verify the changes, run:

You should get this result:

That’s it, ClamAV is ready to use along with SELinux.

Step 3 — Configuring ClamAV

Before Clam configuration can be enabled, you need to remove Example string from the configuration file:

Next, you will have to specify the server type. Open configuration file with your favorite text editor, in this example we will use nano. If it’s not already installed, install it using yum:

Open the configuration file:

Scroll to this line:

#LocalSocket /var/run/clamd.scan/clamd.sock

And change it to:

LocalSocket /var/run/clamd.scan/clamd.sock

Save the changes by hitting CTRL + X shortcut (or COMMAND+X if you are on MAC).

Almost done, now remove Example string from ClamAV’s freshclam update engine configuration file:

Run virus definition database update:

You should get similar output:

Lastly, start Clamd service and run in on boot:


You have just taken one of the steps to secure your server by installing ClamAV on CentOS 7. You can now scan your server against malware and viruses


source :

Posted on: November 6, 2017, by :  | 11 views

Leave a Reply