ConfigServer Services
Server Management Services from Way to The Web Ltd

Installing ClamAV with MailScanner

These instructions will configure ClamAV to use the clamd daemon:

These instructions are only to be used when installing MailScanner without our MSFE (MailScanner Front-End). MSFE now uses the cPanel provided Clamavconnector for virus scanning which is now installed automatically when you install MSFE.

  • Make sure clamavconnector is NOT installed in WHM > Manage Plugins as this will break MailScanner

  • If you would like to verify ClamAV's digital signatures on the virus definition files as they are updated through freshclam, you need to install GMP first:
    /scripts/ensurerpm gmp gmp-devel bzip2-devel

  • Next you will need to create a user for clamav to use:
    useradd clamav
    Some OS's require you to add the group as well:
    groupadd clamav
    Don't worry if the user and/or group already exist.

  • Create and chown the /usr/local/share/clamav directory:
    mkdir /usr/local/share/clamav
    chown clamav:clamav /usr/local/share/clamav

  • Download the latest stable ClamAV distribution from

  • Expand the distribution and cd into the resultant directory and build ClamAV using:
    tar -xzf clamav-*
    cd clamav*
    ./configure --disable-zlib-vcheck
    make install

  • mv -fv /usr/local/etc/freshclam.conf.sample /usr/local/etc/freshclam.conf
    pico -w /usr/local/etc/freshclam.conf

    Comment out the line (put a # as the first character on the line) near the top that says simply:

  • mv -fv /usr/local/etc/clamd.conf.sample /usr/local/etc/clamd.conf
    pico -w /usr/local/etc/clamd.conf

    Comment out the line (put a # as the first character on the line) near the top that says simply:

  • pico -w /usr/local/etc/clamd.conf
    Change the following line:
    #LocalSocket /tmp/clamd.socket
    to this:
    LocalSocket /tmp/clamd

  • Run ldconfig to create the necessary links and cache to most recent shared libraries

  • Run freshclam to download the latest definitions:

  • For CentOS/CloudLinux versions up to/including v6.x:

    Install the example init script that we provide:
    curl -o /etc/init.d/clamd
    chown root:root /etc/init.d/clamd
    chmod +x /etc/init.d/clamd
    chkconfig clamd on
    service clamd restart

  • For CentOS/CloudLinux  v7.x:

    Install the example systemd script that we provide:
    rm -fv /etc/init.d/clamd
    curl -o /usr/lib/systemd/system/clamd.service
    systemctl daemon-reload
    systemctl enable clamd.service
    systemctl restart clamd.service

  • pico -w /etc/chkserv.d/clamav
    Add the following line:
    service[clamav]=x,x,x,service clamd restart,clamd,root

  • Create an empty log file for clamav updates:
    touch /var/log/clam-update.log
    chown clamav:clamav /var/log/clam-update.log

  • Add clamav to chkservd so that it will be monitored:
    pico -w /etc/chkserv.d/chkservd.conf

  • At this point you can setup clamd in the MailScanner configuration:
    pico -w /usr/mailscanner/etc/MailScanner.conf

    Set the following options:
    Virus Scanners = clamd
    Clamd Socket = /tmp/clamd

  • Then restart MailScanner with:
    service MailScanner restart

  • You can now set what domains you want scanned for viruses in:

That's it. If you don't feel confident doing any of this yourself, or if you get into a horrible mess, we offer a cheap package to do it all for you, and more, over here.

*Remember that adding virus scanning of emails to MailScanner will add load to your server.