Install clamav on Centos 7

Installing clamav on previous Centos version was very easy for me.  When I tried to install on Centos 7. I had to learn many things from scratch!..

Install EPEL repo

Clamav is available on EPEL repo. Please install EPEL first then, run the following command:

# yum install clamav-server clamav-data clamav-update clamav-filesystem clamav clamav-scanner-systemd clamav-devel clamav-lib clamav-server-systemd

Remove “Example” line from freshclam.conf and /etc/clamd.d/scan.conf in default locatiof of clamd.conf!

#sed -i -e “s/^Example/#Example/” /etc/freshclam.conf

#sed -i -e “s/^Example/#Example/” /etc/clamd.d/scan.conf

Run freshclam to update database manually.

# freshclam

Btw, fresclam is run by cron job from /etc/cron.d/clamav-update 

# cat /etc/cron.d/clamav-update
## Adjust this line…

## It is ok to execute it as root; freshclam drops privileges and becomes
## user ‘clamupdate’ as soon as possible
0  */3 * * * root /usr/share/clamav/freshclam-sleep

# /usr/share/clamav/freshclam-sleep
WARNING: update of clamav database is disabled; please see
for information how to enable the periodic update resp. how to turn
off this message.

It seems that freshclam update via cron is disabled. Remove the last line (REMOVE ME) from /etc/sysconfig/freshclam file to active…

# tail /etc/sysconfig/freshclam
## ‘disabled-warn’  …  disables the automatic freshclam update and
##                         gives out a warning
## ‘disabled’       …  disables the automatic freshclam silently

### !!!!! REMOVE ME !!!!!!
### REMOVE ME: By default, the freshclam update is disabled to avoid
### REMOVE ME: network access without prior activation
FRESHCLAM_DELAY=disabled-warn    # REMOVE ME

run clamd manually for testing purposes

#/usr/sbin/clamd -c /etc/clamd.d/scan.conf –nofork=yes
ERROR: Please define server type (local and/or TCP)

Himm.. We need to define server type. I suggest to use socket option.

Comment out the following line in /etc/clamd.d/scan.conf

#LocalSocket /var/run/clamd.scan/clamd.sock


LocalSocket /var/run/clamd.scan/clamd.sock

Enable on startup

# systemctl  enable clamd@scan
ln -s ‘/usr/lib/systemd/system/clamd@scan.service’ ‘/etc/systemd/system/’

and start the service, check the status

# systemctl  start clamd@scan
# systemctl  status clamd@scan
clamd@scan.service – Generic clamav scanner daemon
   Loaded: loaded (/usr/lib/systemd/system/clamd@scan.service; enabled)
   Active: active (running) since Mon 2015-01-05 14:45:08 EET; 3s ago
 Main PID: 13588 (clamd)
   CGroup: /system.slice/system-clamd.slice/clamd@scan.service
           └─13588 /usr/sbin/clamd -c /etc/clamd.d/scan.conf –nofork=yes

Jan 05 14:45:08 Centos7-min systemd[1]: Started Generic clamav scanner daemon.
Jan 05 14:45:08 Centos7-min clamd[13588]: clamd daemon 0.98.5 (OS: linux-gnu, ARCH: x86_64, CPU: x86_64)
Jan 05 14:45:08 Centos7-min clamd[13588]: Running as user clamscan (UID 995, GID 994)
Jan 05 14:45:08 Centos7-min clamd[13588]: Log file size limited to 1048576 bytes.
Jan 05 14:45:08 Centos7-min clamd[13588]: Reading databases from /var/lib/clamav
Jan 05 14:45:08 Centos7-min clamd[13588]: Not loading PUA signatures.
Jan 05 14:45:08 Centos7-min clamd[13588]: Bytecode: Security mode set to “TrustSigned”.

Run a test scan:

# clamdscan -c /etc/clamd.d/scan.conf /etc/hosts
/etc/hosts: OK

———– SCAN SUMMARY ———–
Infected files: 0
Time: 0.002 sec (0 m 0 s)


Install clamav on Centos 7

9 thoughts on “Install clamav on Centos 7

  1. Jason Lee says:

    Thank you sir! I’m seeking the way to start the clad on CentOS 7 on past serval days… I got it finally, Many thanks!


  2. Kalle says:

    I got this error message:
    “SELinux is preventing /usr/sbin/clamd from read access on the file filesystems.”

    I had to write this command to get it working with SELinux:
    “sudo setsebool -P antivirus_can_scan_system 1”

    Liked by 1 person

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s