1. Install the EPEL Repository
To begin, you need to install the EPEL repository. Depending on your CentOS version and architecture, use one of the following commands:
2. Install ClamAV
With the EPEL repository enabled, install ClamAV and its daemon:
yum install clamav clamd
3. Start and Enable ClamAV
Start the clamd
service and configure it to start automatically on boot:
/etc/init.d/clamd start
chkconfig clamd on
4. Update ClamAV Signatures
Update the virus definitions for ClamAV:
/usr/bin/freshclam
Note: ClamAV will automatically update its definitions daily via the cron job located in /etc/cron.daily/freshclam
.
5. Configure Daily Scans
To set up a daily scan, create a new cron job that will scan your desired directory (e.g., /var/www
). Create a script for the scan:
nano /etc/cron.daily/man_clamscan
Add the following content to the script, adjusting SCAN_DIR
to the directory you want to scan:
#!/bin/bash
SCAN_DIR="/var/www"
LOG_FILE="/var/log/clamav/man_clamscan.log"
/usr/bin/clamscan -i -r $SCAN_DIR >> $LOG_FILE
Make the script executable:
chmod +x /etc/cron.daily/man_clamscan
Conclusion
You have now set up ClamAV on CentOS, configured it to start on boot, updated its virus definitions, and scheduled daily scans of your specified directory. Regular scans will help ensure that your system remains secure.