ClamAV® is an open source (GPL) anti-virus engine used in a variety of situations including email scanning, web scanning, and end point security. It provides a number of utilities including a flexible and scalable multi-threaded daemon, a command line scanner and an advanced tool for automatic database updates.
Install ClamAV on Ubuntu 18.04
sudo apt install clamav clamav-daemon -y
Permission to Directories where log save (For Eg. in my case)
sudo chmod 777 /var/log/clamav/
sudo chmod 777 /var/lib/clamav/
Update the ClamAV Singature Database
systemctl stop clamav-freshclam
freshclam
sudo systemctl start clamav-freshclam
While downloading ClamAV Signature if facing timeout issue then modify below configuration
sudo gedit /etc/clamav/freshclam.conf
Change below parameters in configuration file
ConnectTimeout 30
ReceiveTimeout 30
To
ConnectTimeout 9999sudo apt install clamav clamav-daemon -y
ReceiveTimeout 9999
Clamscan command execution
clamscan --help
In PHP you can write simple script to execute clamscan as below
<?php
exec('clamscan [/path-to-file/file-name.ext]', $output, $result);
if($result == 1){
// Virus Infected
}else{
// Virus not found
}
?>