Centos7.2安装Clamav-0.101.2

文章目录

      • 步骤一:下载编译安装包
      • 步骤二:解压编译安装clamav
      • 步骤三:添加软连接
      • 步骤四:创建相关文件
      • 步骤五:修改配置文件
      • 步骤六:创建clamav用户并授权
      • 步骤七:启动clamd
      • 步骤八:添加定时任务,扫描会占用IO

步骤一:下载编译安装包

[root@liang /root 20:00:48]#cd /server/Package/
[root@liang /server/Package 20:00:50]#wget http://www.clamav.net/downloads/production/clamav-0.101.2.tar.gz

步骤二:解压编译安装clamav

[root@liang /server/Package 20:01:05]#tar zxf clamav-0.101.2.tar.gz
[root@liang /server/Package 20:01:20]#cd clamav-0.101.2
[root@liang /server/Package/clamav-0.101.2 20:02:24]#yum install gcc-c++ openssl openssl-devel -y
[root@liang /server/Package/clamav-0.101.2 11:07:27]#./configure --prefix=/usr/local/clamav-0.101.2
[root@liang /server/Package/clamav-0.101.2 11:07:49]#make && make install

步骤三:添加软连接

[root@liang /server/Package/clamav-0.101.2 11:10:30]#ln -s /usr/local/clamav-0.101.2/ /server/clamav
[[root@liang /server/Package/clamav-0.101.2 11:10:30]#lln -s /usr/local/clamav-0.101.2/bin/* /usr/local/bin/
[root@liang /server/Package/clamav-0.101.2 11:10:30]#lln -s /usr/local/clamav-0.101.2/sbin/* /usr/local/sbin/

步骤四:创建相关文件

[root@liang /server/Package/clamav-0.101.2 11:10:56]#cd /server/clamav/
[root@liang /server/clamav 11:11:09]#mkdir logs
[root@liang /server/clamav 11:11:31]#touch logs/clamd.log
[root@liang /server/clamav 11:11:44]#touch logs/freshclam.log
[root@liang /server/clamav 11:11:53]#mkdir updata

步骤五:修改配置文件

[root@liang /server/clamav/etc 11:12:40]#ls
clamd.conf.sample freshclam.conf.sample
[root@liang /server/clamav/etc 11:12:40]#cp clamd.conf.sample clamd.conf
[root@liang /server/clamav/etc 11:12:57]#cp freshclam.conf.sample freshclam.conf
[root@liang /server/clamav/etc 11:14:07]#cat >> clamd.conf<<-eof
> LocalSocket /server/clamav/clamd.socket
> PidFile /server/clamav/updata/clamd.pid
> DatabaseDirectory /server/clamav/updata
> LogFile /server/clamav/logs/clamd.log
> eof
[root@liang /server/clamav/etc 11:15:08]#cat >>freshclam.conf<<-eof
> DatabaseDirectory /server/clamav/updata
> UpdateLogFile /server/clamav/logs/freshclam.log
> PidFile /server/clamav/updata/freshclam.pid
> eof
[root@liang /server/clamav/etc 11:17:02]#grep -n “#Example” clamd.conf freshclam.conf
clamd.conf:8:#Example #原本是未注释的,添加#进行注释
freshclam.conf:8:#Example #原本是未注释的,添加#进行注释

步骤六:创建clamav用户并授权

[root@liang /server/clamav/etc 11:18:15]#useradd -M -s /sbin/nologin clamav
[root@liang /server/clamav/etc 11:19:10]#chown -R clamav:clamav /usr/local/clamav-0.101.2/

步骤七:启动clamd

[root@liang /server/clamav/etc 11:20:56]#clamd start
LibClamAV Error: cl_load(): No such file or directory: /server/clamav/updata
ERROR: Can’t get file status
启动报错,提示的意思是 /server/clamav/updata目录中没有东西,需要freshclam 更新病毒库
[root@liang /server/clamav/etc 11:41:18]#freshclam
ClamAV updata process started at Wed Jun 26 11:41:26 2019
main.cvd is up to date (version: 58, sigs: 4566249, f-level: 60, builder: sigmgr)
nonblock_recv: recv timing out (30 secs)
WARNING: getfile: Download interrupted: Operation now in progress (IP: 104.16.219.84)
WARNING: Can’t download daily.cvd from database.clamav.net
Trying again in 5 secs…
main.cvd is up to date (version: 58, sigs: 4566249, f-level: 60, builder: sigmgr)
Downloading daily.cvd [100%]
daily.cvd updatad (version: 25492, sigs: 1602058, f-level: 63, builder: raynman)
Downloading bytecode.cvd [100%]
bytecode.cvd updatad (version: 328, sigs: 94, f-level: 63, builder: neo)
Database updatad (6168401 signatures) from database.clamav.net (IP: 104.16.219.84)
[root@liang /server/clamav/etc 12:00:32]#clamd start
[root@liang /server/clamav/etc 12:01:31]#clamd start
[root@liang /server/clamav/etc 12:04:51]#ps -ef|grep clamd
root 5645 1 0 12:02 ? 00:00:00 clamd start
root 5688 5545 0 12:05 pts/0 00:00:00 grep --color=auto clamd

步骤八:添加定时任务,扫描会占用IO

[root@liang /server/clamav/etc 12:04:51]#crontab -l
*/5 * * * * /usr/sbin/ntpdate ntp1.aliyun.com >/dev/null 2>&1
00 00 * * * /usr/local/bin/freshclam
00 00 * * * /usr/local/bin/clamscan -r /tmp/ --remove

你可能感兴趣的:(Linux运维)