#/bin/bash #clamav用户和用户组 groupadd clamav && useradd -g clamav clamav && id clamav #日志存放目录 mkdir -p /usr/local/clamav/logs 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 #病毒存放目录 mkdir -p /usr/local/clamav/updata chown -R root.clamav /usr/local/clamav/ chown -R clamav.clamav /usr/local/clamav/updata/ #解压安装包 tar -zxvf clamav-0.101.2.tar.gz cd clamav-0.101.2 #安装依赖 yum install gcc gcc-c++ openssl openssl-devel -y #编译安装 ./configure --prefix=/usr/local/clamav make && make install cd /usr/local/clamav/etc cp clamd.conf.sample clamd.conf cp freshclam.conf.sample freshclam.conf #修改配置文件 sed -i "8s/^/#/g" /usr/local/clamav/etc/clamd.conf sed -i "8s/^/#/g" /usr/local/clamav/etc/freshclam.conf echo " LogFile /usr/local/clamav/logs/clamd.log PidFile /usr/local/clamav/updata/clamd.pid DatabaseDirectory /usr/local/clamav/updata ">>/usr/local/clamav/etc/clamd.conf echo " DatabaseDirectory /usr/local/clamav/updata UpdateLogFile /usr/local/clamav/logs/freshclam.log PidFile /usr/local/clamav/updata/freshclam.pid ">>/usr/local/clamav/etc/freshclam.conf chown -R clamav.clamav /usr/local/clamav/ #启动 clamav systemctl start clamav-freshclam.service systemctl enable clamav-freshclam.service systemctl status clamav-freshclam.service #让服务器每天晚上定时更新和杀毒,保存杀毒日志,crontab文件如下: 10 2 * * * /usr/local/clamav/bin/freshclam --quiet 20 3 * * * /usr/local/clamav/bin/clamscan -r /home --remove -l /var/log/clamscan.log