How to Install ClamAV on CentOS 7

How to Install ClamAV on CentOS 7

View: 3,911 and 2 years ago in VPS

Introduction

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.

Table of Contents

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:

yum -y install epel-release
yum clean all

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

 yum -y install clamav-server clamav-data clamav-update clamav-filesystem clamav clamav-scanner-systemd clamav-devel clamav-lib clamav-server-systemd

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:

 setsebool -P antivirus_can_scan_system 1
 setsebool -P clamd_use_jit 1

To verify the changes, run:

getsebool -a | grep antivirus

You should get this result:

antivirus_can_scan_system --> on
antivirus_use_jit --> off

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:

sed -i -e "s/^Example/#Example/" /etc/clamd.d/scan.conf

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:

yum install nano -y

Open the configuration file:

nano /etc/clamd.d/scan.conf

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:

sed -i -e "s/^Example/#Example/" /etc/freshclam.conf

Run virus definition database update:

freshclam

You should get similar output:

ClamAV update process started at Tue Dec 19 09:30:20 2016
main.cvd is up to date (version: 57, sigs: 4218790, f-level: 60, builder: amishhammer)
Trying host database.clamav.net (69.163.100.14)...
Downloading daily.cvd [100%]
daily.cvd updated (version: 22739, sigs: 1100989, f-level: 63, builder: neo)
Downloading bytecode-279.cdiff [100%]
Downloading bytecode-280.cdiff [100%]
Downloading bytecode-281.cdiff [100%]
Downloading bytecode-282.cdiff [100%]
Downloading bytecode-283.cdiff [100%]
bytecode.cld updated (version: 285, sigs: 57, f-level: 63, builder: bbaker)
Database updated (5319836 signatures) from database.clamav.net (IP: 168.143.19.95)

Lastly, start Clamd service and run in on boot:

 systemctl start [email protected]
 systemctl enable [email protected]

Conclusion


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.

Other Tutorials

How to Change Permissions and Owners via Command Line
2 years ago
How to Change Permissions and Owners via Command Line
Read More
How to Create Apache Virtual Hosts on CentOS 7
2 years ago
How to Create Apache Virtual Hosts on CentOS 7
Read More
How to Install Cachet Status Page System on CentOS 7
2 years ago
How to Install Cachet Status Page System on CentOS 7
Read More
How to Install cPanel/WHM on CentOS 7
2 years ago
How to Install cPanel/WHM on CentOS 7
Read More
How to Install Django on Ubuntu 16.04
2 years ago
How to Install Django on Ubuntu 16.04
Read More
How to Install Let’s Encrypt SSL on CentOS 7 Running Apache Web Server
2 years ago
How to Install Let’s Encrypt SSL on CentOS 7 Running Apache Web Server
Read More

Subscribe for our monthly newsletter