環境 CentOS: 7.x 下載 下載地址 :http://www.clamav.net/downloads,使用目前最新版本為:clamav 0.101.3 使用 wget 下載 安裝 1. 解壓 2. 安裝依賴 3. 編譯安裝 4. 添加用戶 配置 1. 創建日誌目錄和病毒庫目錄 2. 創建日 ...
環境
CentOS: 7.x
下載
下載地址 :http://www.clamav.net/downloads,使用目前最新版本為:clamav-0.101.3
使用 wget 下載
wget https://clamav-site.s3.amazonaws.com/production/release_files/files/000/000/484/original/clamav-0.101.3.tar.gz?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIY6OSGQFGUNJQ7GQ%2F20190812%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190812T053848Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=965dd9d950d9337bf792a5af2b0fb009dd08fc2533f2b262504a778739439b64
安裝
- 解壓
tar -zxvf clamav-0.101.3.tar.gz
- 安裝依賴
yum install gcc gcc-c++ openssl openssl-devel -y
- 編譯安裝
cd clamav-0.101.3
./configure --prefix=/usr/local/clamav
make && make install
- 添加用戶
groupadd clamav
useradd -g clamav clamav
配置
- 創建日誌目錄和病毒庫目錄
mkdir /usr/local/clamav/logs
mkdir /usr/local/clamav/updata
- 創建日誌文件
touch /usr/local/clamav/logs/clamd.log
touch /usr/local/clamav/logs/freshclam.log
- 文件授權
chown clamav:clamav /usr/local/clamav/logs/clamd.log
chown clamav:clamav /usr/local/clamav/logs/freshclam.log
chown clamav:clamav /usr/local/clamav/updata
chown -R clamav.clamav /usr/local/clamav/
- 修改配置文件
cp /usr/local/clamav/etc/clamd.conf.sample /usr/local/clamav/etc/clamd.conf
cp /usr/local/clamav/etc/freshclam.conf.sample /usr/local/clamav/etc/freshclam.conf
vim /usr/local/clamav/etc/clamd.conf
// 註釋掉第8行,如下
#Example
#添加以下內容
LogFile /usr/local/clamav/logs/clamd.log
PidFile /usr/local/clamav/updata/clamd.pid
DatabaseDirectory /usr/local/clamav/updata
vim /usr/local/clamav/etc/freshclam.conf
// 註釋掉第8行,如下
#Example
#添加以下內容
DatabaseDirectory /usr/local/clamav/updata
UpdateLogFile /usr/local/clamav/logs/freshclam.log
PidFile /usr/local/clamav/updata/freshclam.pid
執行
創建軟鏈接:
ln -s /usr/local/clamav/bin/clamscan /usr/local/sbin/clamscan
- 更新病毒庫
/usr/local/clamav/bin/freshclam
- 啟動
# 啟動
systemctl start clamav-freshclam.service
# 開機啟動
systemctl enable clamav-freshclam.service
# 查看狀態
systemctl status clamav-freshclam.service
- 掃描殺毒
參數:
-r 遞歸掃描子目錄
-i 只顯示發現的病毒文件
–no-summary 不顯示統計信息
用法:
# 幫助
/usr/local/clamav/bin/clamscan --help
# 預設掃描當前目錄下的文件,並顯示掃描結果統計信息
/usr/local/clamav/bin/clamscan
#掃描當前目錄下的所有目錄和文件,並顯示結果統計信息
/usr/local/clamav/bin/clamscan -r
#掃描data目錄下的所有目錄和文件,並顯示結果統計信息
/usr/local/clamav/bin/clamscan -r /data
#掃描data目錄下的所有目錄和文件,只顯示有問題的掃描結果
/usr/local/clamav/bin/clamscan -r --bell -i /data
#掃描data目錄下的所有目錄和文件,不顯示統計信息
/usr/local/clamav/bin/clamscan --no-summary -ri /data
定時更新和殺毒
crontab定時任務,讓伺服器每天定時更新和定時殺毒,保存殺毒日誌。
echo "
10 2 * * * /usr/local/clamav/bin/freshclam --quiet
20 3 * * * /usr/local/clamav/bin/clamscan -r /home --remove -l /var/log/clamscan.log
">>crontab
安裝配置腳本