Install ClamAV on a CentOS 6 VPS with DirectAdmin

ClamIn today’s article on our blog we are going to install ClamAV on a CentOS 6 VPS with DirectAdmin control panel. We are offering DirectAdmin for free with all our VPS hosting plans.

Clam AntiVirus or ClamAV is very popular and widely used, free and open source antivirus application for Unix like systems. It is designed for detecting over 750.000 viruses, trojans, worms, mobile malware and other malicious software on your server. ClamAV is especially used on email servers as server-side email scanner.

The installation is pretty fast and easy, even if you are not comfortable with the Linux command line. Let’s start the installation.

Login to your server as user ‘root’ and first of all, make sure that your server is up-to-date by executing the following command:

# yum update

Change the current working directory to DirectAdmin’s custombild directory

# cd /usr/local/directadmin/custombuild

and compile ClamAV by executing the following commands:

./build update
./build set clamav yes
./build clamav

After the compiling is done, you may get the following error message when ClamAV will try to start:

Starting clamd: LibClamAV Error: cli_loaddb(): No supported database files found in /usr/share/clamav
ERROR: Can't open file or directory

It means thare is no ClamAV virus database on your server. The database can be easily generated:

# freshclam -v

And start ClamAV:

# /etc/init.d/clamd start

Done. The installation of ClamAV is really that easy.

Now, we will integrate ClamAV with Exim.

Using your favorite text editor, edit Exim’s configuration file and add the following line before the “primary_hostname =” line

# nano /etc/exim.conf
av_scanner = clamd: 3310

Next, find the ‘check_message:‘ line and add the following lines below it:

deny message = This message contains malformed MIME ($demime_reason)
demime = *
condition = ${if >{$demime_errorlevel}{2}{1}{0}}
deny message = This message contains a virus or other harmful content ($malware_name)
demime = *
malware = */defer_ok
deny message = This message contains an attachment of a type which we  do not accept (.$found_extension)
demime = bat:com:pif:prf:scr:vbs
warn message = X-Antivirus-Scanner: Clean mail though you should still use an Antivirus

Save the changes and restart Exim

# service exim restart

Now you have ClamAV installed and integrated with Exim on your CentOS 6 DirectAdmin VPS.

Using ClamAV you can scan single files, directories or an entire server.

To check all files in a specific directory use:

# clamscan -r -i /path/to/directory

To check all files on your server use:

# clamscan -r -i /

-i flag will only pring the infected files.
-r flag will scan the directories and subdirectories recursively.

To see all available options execute:

# clamscan --help

Of course you don’t have to do any of this if you use one of our Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to install ClamAV for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

How to Install the Ghost blogging platform on Debian Wheezy with Nginx
Install Nextcloud on Ubuntu 16.04
Install WordPress on Debian VPS
There are currently no comments.