Environment:
- AlmaLinux / CloudLinux 8/9
- WHM/cPanel (v126+)
- Root SSH access
π§ Step 1: Install ClamAV via WHM
- Login to WHM as root.
- Go to:
WHM >> cPanel >> Manage Plugins - Check the box for:
β clamavconnector β Install and Keep Updated - Click Save at the bottom of the page.
- WHM will now install ClamAV under
/usr/local/cpanel/3rdparty/bin/.
π Step 2: Update ClamAV Virus Definitions
SSH into your server and run:
freshclam
If the command is not found, continue to Step 6 (symlink fix).
π§ͺ Step 3: Scan the /home Directory and Save Output
clamscan -ir /home > logs.txt
-i: Only print infected files.-r: Recursive scan.logs.txt: Output file in current directory.
β Step 4: If You See -bash: clamscan: command not found
Run:
/scripts/restartsrv_clamd
If you see “Unable to locate clamd”, proceed to Step 5.
π¦ Step 5: Manually Install ClamAV (Optional/Fallback)
If the WHM install fails or you need a system-wide install:
For AlmaLinux 8/9 or CloudLinux 8/9:
dnf install epel-release -y
dnf install clamav clamav-update -y
freshclam
Then restart clamd if installed:
systemctl enable --now clamd@scan
You can now use clamscan normally.
π Step 6: Fix WHM Install Not Available via CLI
If WHM installation succeeded but clamscan/freshclam don’t work from CLI:
A. Confirm installation paths:
ls -lah /usr/local/cpanel/3rdparty/bin/*clam*
You should see binaries like clamscan, clamd, freshclam.
B. Check if they exist in /usr/local/bin:
ls -l /usr/local/bin/*clam*
If not, create symbolic links:
ln -s /usr/local/cpanel/3rdparty/bin/freshclam /usr/local/bin/freshclam
ln -s /usr/local/cpanel/3rdparty/bin/clamscan /usr/local/bin/clamscan
ln -s /usr/local/cpanel/3rdparty/bin/clamd /usr/local/bin/clamd
ln -s /usr/local/cpanel/3rdparty/bin/clamav-config /usr/local/bin/clamav-config
Confirm:
ls -l /usr/local/bin/*clam*
π Step 7: Scan Public Web Content
To scan all public_html directories of all users:
clamscan -ir /home/*/public_html > /usr/local/src/scan.txt
β
Result stored in: /usr/local/src/scan.txt
π Step 8: View the Scan Results
cat /usr/local/src/scan.txt
π Optional Tips
- Add to cron for weekly scans:
crontab -eExample weekly scan entry:0 3 * * 0 clamscan -ir /home/*/public_html > /usr/local/src/weekly_scan.txt - Schedule
freshclamto update hourly:echo "0 * * * * /usr/local/bin/freshclam --quiet" >> /etc/crontab
