Status: This OS is no longer supported
This article, “Install ClamAV on a CentOS 6 VPS with DirectAdmin,” covers a version of CentOS that reached end of life (EOL). As it is no longer supported. We will no longer maintain this guide. If you are currently operating a server running CentOS 6, we highly recommend contacting RoseHosting’s fully managed support. They can upgrade or migrate you to a supported version of AlmaLinux.
In 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 was 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.
Installation
Firstly, log in 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
Next, 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 compilation is done, you may get the following error message when ClamAV tries 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 there 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:127.0.0.1 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
You’ve Installed ClamAV on CentOS 6
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 or simply leave a reply below. Thanks.