tar -xzf clamav.tar.gz
cd clamav/
./clamav.sh
source /etc/profile
- clamav-1.3.0.linux.x86_64.rpm
- clamav virus database
- main.cvd:http://database.clamav.net/main.cvd
- daily.cvd:http://database.clamav.net/daily.cvd
- bytecode.cvd:http://database.clamav.net/bytecode.cvd
- clamav.sh
# 1. Installation clamav
rpm -ivh --prefix=/usr/local/clamav clamav-1.3.0.linux.x86_64.rpm
echo PATH=/usr/local/clamav/bin:/usr/local/clamav/sbin:$PATH > /etc/profile.d/path.sh
# 2. Configuration clamav: clamav.conf and freshclam.conf
echo '/usr/local/clamav/lib64/' | sudo tee -a /etc/ld.so.conf.d/clamav.conf
ldconfig
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
ln -s /usr/local/clamav/etc/freshclam.conf /usr/local/etc/
ln -s /usr/local/clamav/etc/clamd.conf /usr/local/etc/
sed -i '8s|Example|#Example|' /usr/local/clamav/etc/clamd.conf
cat << EOF >> /usr/local/clamav/etc/clamd.conf
LogFile /var/log/clamav/clamd.log
LogFileMaxSize 20M
PidFile /usr/local/clamav/clamd.pid
DatabaseDirectory /var/lib/clamav
LocalSocket /usr/local/clamav/socket/clamd.sock
EOF
sed -i '8s|Example|#Example|' /usr/local/clamav/etc/freshclam.conf
cat << EOF >> /usr/local/clamav/etc/freshclam.conf
DatabaseDirectory /var/lib/clamav
UpdateLogFile /var/log/clamav/freshclam.log
PidFile /usr/local/clamav/pid/freshclam.pid
DatabaseMirror database.clamav.net
Checks 24
EOF
# 2. Create a service user account (and group)
groupadd clamav
useradd -g clamav -s /bin/false -c "Clam Antivirus" clamav
chown -R clamav:clamav /usr/local/clamav
mkdir /var/log/clamav
chown -R clamav:clamav /var/log/clamav
mkdir /var/lib/clamav
chown -R clamav:clamav /var/lib/clamav
# 3. Copy offline file or execute freshclam download virus database
cp *.cvd /var/lib/clamav
# 4. Configuration clamd.service
cat << EOF >> /usr/lib/systemd/system/clamd.service
[Unit]
Description=Clam AntiVirus userspace daemon
Documentation=man:clamd(8) man:clamd.conf(5) https://docs.clamav.net/
# Check for database existence
ConditionPathExistsGlob=/var/lib/clamav/main.{c[vl]d,inc}
ConditionPathExistsGlob=/var/lib/clamav/daily.{c[vl]d,inc}
[Service]
type=simple
ExecStart=/usr/local/clamav/sbin/clamd --foreground=true
# Reload the database
ExecReload=/bin/kill -USR2 $MAINPID
StandardOutput=syslog
TimeoutStartSec=420
[Install]
WantedBy=multi-user.target
EOF
systemctl start clamd.service
systemctl status clamd.service
systemctl enable clamd.service
标签:部署,clamav,etc,clamd,usr,conf,local
From: https://www.cnblogs.com/swallow010/p/18091265