• 运行 Clamav 为 daemon 模式
    • Ubuntu 16.04 下安装
      • 安装clamav-daemon和clamav-freshclam
      • 修改clamd配置文件,建议以root权限运行clamd进程:
      • 启动clamav-daemon
    • CentOS 7 下安装
      • 安装 Clamd 相关组件
      • 配置Freshclam
      • 配置 Clamd
      • 运行 Clamd

    运行 Clamav 为 daemon 模式

    Ubuntu 16.04 下安装

    安装clamav-daemon和clamav-freshclam

    1. apt-get install clamav-daemon clamav-freshclam

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

    /etc/clamav/clamd.conf

    1. LocalSocketGroup root
    2. User root

    启动clamav-daemon

    1. systemctl start clamav-daemon
    • 测试Clamd工作效果:
      1. clamdscan /dir/PATH

    CentOS 7 下安装

    安装 Clamd 相关组件

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

    配置Freshclam

    • 按照以下方式配置Freshclam,以定期自动更新病毒库:

      1. cp /etc/freshclam.conf /etc/freshclam.conf.bak
      2. sed -i '/^Example/d' /etc/freshclam.conf
    • 创建一个启动脚本:/usr/lib/systemd/system/clam-freshclam.service

      1. # 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

    • 设置开机自启并启动 Freshclam
      1. systemctl enable clam-freshclam.service
      2. systemctl start clam-freshclam.service

    配置 Clamd

    • 拷贝配置文件模版

      1. cp /usr/share/clamav/template/clamd.conf /etc/clamd.conf
    • 启用配置文件

      1. sed -i '/^Example/d' /etc/clamd.conf
    • 如下所示,修改配置文件中的相应内容

      1. User root
      2. LocalSocket /var/run/clamd.sock
      3. ...

    运行 Clamd

    • 创建启动脚本:/etc/init.d/clamd
      1. case "$1" in
      2. start)
      3. echo -n "Starting Clam AntiVirus Daemon... "
      4. /usr/sbin/clamd
      5. RETVAL=$?
      6. echo
      7. [ $RETVAL -eq 0 ] && touch /var/lock/subsys/clamd
      8. ;;
      9. stop)
      10. echo -n "Stopping Clam AntiVirus Daemon... "
      11. pkill clamd
      12. rm -f /var/run/clamav/clamd.sock
      13. rm -f /var/run/clamav/clamd.pid
      14. RETVAL=$?
      15. echo
      16. [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/clamd
      17. ;;
      18. esac
    1. chmod +x /etc/init.d/clamd
    • 设置开机自启并启动 Clamd

      1. chkconfig clamd on
      2. service clamd start
    • 测试Clamd工作效果:

      1. clamdscan /dir/PATH

    原文: https://manual-cn.seafile.com/deploy_pro/deploy_clamav_as_daemon.html