🔍
Security

Scanning a Website with ClamAV: Setup, Commands and Reading the Results

23.11.2026
← All articles

ClamAV is an open-source antivirus engine and one of the most widely used tools for checking files on Linux servers. When a site suddenly slows down, a search engine starts showing a "this site may be harmful" warning, or your host reports outgoing spam, scanning the files is one of the first things to do. Below we walk through installing ClamAV, scanning a site directory and drawing sensible conclusions from the output.

What ClamAV catches and what it can miss

ClamAV compares files against a signature database in which every known threat has a characteristic fingerprint. That makes it good at spotting common trojans, well-known web shells, phishing kits and injected JavaScript. However, attackers who target websites often mutate their code for each victim, rename variables and hide the payload in base64, so a fresh variant may simply not be in the database yet. A clean report therefore does not prove the site is clean; it only means no known threats were found. In practice ClamAV works best when combined with a manual search for suspicious code, shown later in this article.

Installing on a VPS or server

On a VPS or dedicated server ClamAV installs from the package manager in minutes. Debian and Ubuntu ship it in the default repositories, while RHEL-family systems such as AlmaLinux need EPEL enabled first. The most important step after installation is updating the signatures, because scanning with an outdated database is close to useless. The freshclam service refreshes the database several times a day, but it is worth running it manually the first time.

# Debian / Ubuntu
sudo apt update
sudo apt install clamav clamav-daemon

# AlmaLinux / Rocky
sudo dnf install epel-release
sudo dnf install clamav clamav-update

# first signature update
sudo systemctl stop clamav-freshclam
sudo freshclam
sudo systemctl start clamav-freshclam

On Debian, running freshclam by hand while the service is active fails with a locked log file error, which is why the service is stopped briefly above. On AlmaLinux the service name may differ; there a plain sudo freshclam is enough.

Scanning the site directory

The main command is clamscan, which walks a directory recursively. The most useful options for websites are -r for subdirectories, -i to list only infected files and --log to save the report. On a large site a scan can take a while and keep the CPU busy, so run it at low priority or the site itself will slow down during the scan.

nice -n 19 ionice -c3 clamscan -r -i \
  --log=/root/scan-example.uz.log \
  /var/www/example.uz

# skip big archives and videos, ignore the cache
nice -n 19 clamscan -r -i --max-filesize=20M --max-scansize=100M \
  --exclude-dir="/var/www/example.uz/cache" \
  /var/www/example.uz

When the scan finishes you get a summary with the number of files scanned, infections found and time taken. Each infected file gets its own line, such as /var/www/example.uz/wp-content/uploads/2024/05/x.php: Php.Webshell.Generic FOUND.

Handling the files it finds

Deleting every flagged file straight away is not always wise. Sometimes the malicious code is appended to a working file such as index.php or a theme's functions.php, and removing it takes the whole site down. It is safer to move files into a quarantine folder first and review them one by one. The --move option does this automatically, but use it only after you have looked at a plain report once.

mkdir -p /root/quarantine
clamscan -r -i --move=/root/quarantine /var/www/example.uz

A PHP file inside an image folder like uploads is almost certainly a backdoor and safe to delete. For CMS core or plugin files, the reliable fix is to download a clean copy of the same version from the official source and replace the file. False positives also happen, for example with security plugins' own signature files, so do not delete blindly.

Finding PHP code ClamAV does not see

New or custom backdoors may not be in the signature database at all. Searching for suspicious function combinations and recently modified files fills that gap. A match does not prove a file is malicious; it gives you a short list to review by hand.

cd /var/www/example.uz
grep -rlE "eval\s*\(\s*(base64_decode|gzinflate|str_rot13)" --include=*.php .
find wp-content/uploads -type f -name "*.php"
find . -type f -name "*.php" -mtime -7 -printf "%TY-%Tm-%Td %p\n" | sort

Consider a small online shop in Tashkent whose customers complained about being redirected to unrelated pages. ClamAV found one malicious JavaScript file in the theme folder, the owner replaced it, and two days later the problem was back. A follow-up find revealed a PHP file in uploads disguised with an image-like name, and that file kept rewriting the infection. This is exactly why the two methods belong together.

Scheduled scans and shared hosting

A nightly cron job catches problems early: a line such as 30 3 * * * root nice -n 19 clamscan -r -i --log=/var/log/clamav/site.log /var/www/example.uz in /etc/cron.d/ is enough to start with. On shared hosting you have no root access and cannot install ClamAV yourself, so download a backup of the site files and scan it on your own machine or a temporary VPS, or ask support to run a scan; sayt.uz customers can request this through a ticket in the cabinet. Whatever the route, the key question afterwards is how the code got in. If the entry point stays open, a cleaned site is usually reinfected within days, so finish every scan by updating the CMS and plugins and changing passwords.

Related articles

🌐 The danger of misconfigured CORS: how to open your API correctly 🦠 Malware on Your PC Steals FTP Passwords: Signs and Protection ✅ Django Security Checklist: What to Verify Before Going to Production 📤 Securing a File Upload Form: Validation, Storage and Delivery
🌐 Language
🇺🇿 O⁠'zbek 🇺🇿 Özbek (yangi) 🇺🇿 Ўзбек 🇷🇺 Русский 🇬🇧 English ✓