运行 Clamav 为 daemon 模式

Ubuntu 18.04 (Ubuntu 20.04)下安装

安装 Clamav-daemon 和 Clamav-freshclam

apt-get install clamav-daemon clamav-freshclam

停止 Clamav-freshclam 程序,手动更新数据库

systemctl stop clamav-freshclam 
sudo freshclam                  ##手动更新数据库,一般都会更新失败,报超时错误,可以使用 wget 命令把数据库下载下来。

##手动下载 clamva 数据库
cd /var/lib/clamav
wget http://database.clamav.net/main.cvd
wget http://database.clamav.net/daily.cvd
wget http://database.clamav.net/bytecode.cvd
chown -R clamav:clamav *

然后在执行一遍:sudo freshclam

systemctl start clamav-freshclam

修改 Clamd 配置文件,建议以 root 权限运行 Clamd 进程:

/etc/clamav/clamd.conf

LocalSocketGroup root
User root

启动Clamav-daemon

systemctl start clamav-daemon

curl https://www.eicar.org/download/eicar.com.txt | clamdscan -

stream: Eicar-Test-Signature FOUND

CentOS 7 下安装

安装 Clamd 相关组件

yum install epel-release
yum install clamav-server clamav-data clamav-filesystem clamav-lib clamav-update clamav clamav-devel

配置 Freshclam

cp /etc/freshclam.conf /etc/freshclam.conf.bak
sed -i '/^Example/d' /etc/freshclam.conf

# Run the freshclam as daemon
[Unit]
Description = freshclam scanner
After = network.target

[Service]
Type = forking
ExecStart = /usr/bin/freshclam -d -c 4
Restart = on-failure
PrivateTmp = true

[Install]
WantedBy=multi-user.target

systemctl enable clam-freshclam.service
systemctl start clam-freshclam.service

##手动下载 clamva 数据库
cd /var/lib/clamav
rm -rf  main.cvd daily.cvd bytecode.cvd
wget http://database.clamav.net/main.cvd
wget http://database.clamav.net/daily.cvd
wget http://database.clamav.net/bytecode.cvd
chown -R  clamupdate:clamupdate  *

然后在执行一遍: freshclam

配置 Clamd

cp  /etc/clamd.d/scan.conf  /etc/clamd.d/scan.conf.bak

sed -i '/^Example/d' /etc/clamd.d/scan.conf

User root
LocalSocket /var/run/clamd.sock
...

运行 Clamd

vim /etc/systemd/system/clamd.service

##把 %i  改成 scan.conf

[Unit]
Description = clamd scanner (scan.conf) daemon
Documentation=man:clamd(8) man:clamd.conf(5) https://www.clamav.net/documents/
After = syslog.target nss-lookup.target network.target

[Service]
Type = forking
ExecStart = /usr/sbin/clamd -c /etc/clamd.d/scan.conf
# Reload the database
ExecReload=/bin/kill -USR2 $MAINPID
Restart = on-failure
TimeoutStartSec=420

[Install]
WantedBy = multi-user.target

systemctl enable clamd.service --now

curl https://www.eicar.org/download/eicar.com.txt | clamdscan -

stream: Eicar-Test-Signature FOUND

Last modified by 郑杰, 2021-07-07

Ubuntu 18.04 (Ubuntu 20.04)下安装
安装 Clamav-daemon 和 Clamav-freshclam
停止 Clamav-freshclam 程序,手动更新数据库
修改 Clamd 配置文件,建议以 root 权限运行 Clamd 进程:
启动Clamav-daemon
CentOS 7 下安装
安装 Clamd 相关组件
配置 Freshclam
配置 Clamd
运行 Clamd