Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get ClamAV running on Mac OS X (using Homebrew)

Get ClamAV running on Mac OS X (using Homebrew)

The easiest way to get the ClamAV package is using Homebrew

$ brew install clamav

Before trying to start the clamd process, you'll need a copy of the ClamAV databases.

Create a freshclam.conf file and configure as so

# /usr/local/etc/clamd.conf
DatabaseMirror database.clamav.net

Then run

$ freshclam -v

to download the ClamAV databases. The output will look something like this:

Current working dir is /usr/local/Cellar/clamav/0.98.1/share/clamav
Max retries == 3
ClamAV update process started at Tue Feb  4 11:31:22 2014
Using IPv6 aware code
Querying current.cvd.clamav.net
TTL: 1694
Software version from DNS: 0.98.1
Retrieving http://database.clamav.net/main.cvd
Trying to download http://database.clamav.net/main.cvd (IP: 81.91.100.173)
Downloading main.cvd [100%]
Loading signatures from main.cvd
Properly loaded 2424225 signatures from new main.cvd
main.cvd updated (version: 55, sigs: 2424225, f-level: 60, builder: neo)
Querying main.55.76.1.0.515B64AD.ping.clamav.net
...

Next we'll need to create a clamd.conf

# /usr/local/etc/clamd.conf
LocalSocket /usr/local/var/run/clamav/clamd.sock

You'll need to ensure that the socket directory exists

$ mkdir /usr/local/var/run/clamav

You should now be able to run

$ clamd

to start the process.

@moooooooo

This comment has been minimized.

moooooooo commented Jul 19, 2016

where you say "create a fresh clam.conf file" you have /usr/local/etc/clamd.conf instead of /usr/local/etc/clamav/freshclam.conf
DatabaseMirror database.clamav.net
should be in/usr/local/etc/clamav/freshclam.conf
cheers

@codewisdom

This comment has been minimized.

codewisdom commented Jul 23, 2016

Thank you! This saved me a lot of time.

@LucasMW

This comment has been minimized.

LucasMW commented Sep 3, 2016

I don't have any clamd but have a family of clam and clamd commands. Is that what you mean?

@fschroder

This comment has been minimized.

fschroder commented Sep 8, 2016

Same here, no clamd with version 0.99.2_1. Should this be reported to brew/clamav?

I would also add that database definitions need to be updated regularly. For example using a cron job

$ crontab -e
# clamav database
10 3 * * * freshclam -v
@shrop

This comment has been minimized.

shrop commented Sep 28, 2016

$ mkdir /usr/local/var/run/clamav should be $ mkdir -p /usr/local/var/run/clamav

@rackoh

This comment has been minimized.

rackoh commented Oct 6, 2016

after installing clamav, clamd is giving error

clamd: command not found

@otheus

This comment has been minimized.

otheus commented Oct 16, 2016

This is a good start, but lots of rough edges here. As rackoh says, clamd is not found, because it's in /usr/local/sbin. Running these as root is required, but then one should change the configuration to run as a user such as _clamav, which requires more detailed setup (creation of log files, chown of database directory, etc).

@otheus

This comment has been minimized.

otheus commented Oct 16, 2016

Also need to know how to actually install the package so that it runs at boot time. Something with lib/pkgconfig I presume

@LostAccount

This comment has been minimized.

LostAccount commented Jan 25, 2017

Could the original instructions be rewritten to consider all the comments made if they are not already. Maybe highlight at the top that instructions have been updated and a date. Just a friendly suggestion. Thank you.

@KorhanOzturk90

This comment has been minimized.

KorhanOzturk90 commented Jan 27, 2017

This documentation needs updating as it's been mentioned in almost all of the comments above.

@gagarine

This comment has been minimized.

gagarine commented Feb 17, 2017

@flickerfly

This comment has been minimized.

flickerfly commented Feb 23, 2017

I was getting this error:

ERROR: Can't create temporary directory /usr/local/homebrew/Cellar/clamav/0.99.2_1/share/clamav/clamav-7e398bf3e9361681c17471131272d423.tmp
Hint: The database directory must be writable for UID 82 or GID 82

I found that I needed to do dscl . -list /Users UniqueID|grep 82 to find the username and then make it the owner of the directory like this sudo chown _clamav /usr/local/homebrew/Cellar/clamav/0.99.2_1/share/clamav/.

Thinking later, maybe I could have changed DatabaseDirectory in freshclam.conf and clamd.conf? I'm not sure.

@BSBjorn

This comment has been minimized.

BSBjorn commented Oct 31, 2017

I'm getting this as error when trying to brew install clamav

Warning: You are using OS X 10.13.
We do not provide support for this pre-release version.
You may encounter build failures or other breakages.
==> Downloading https://www.clamav.net/downloads/production/clamav-0.99.1.tar.gz

curl: (22) The requested URL returned error: 403
Error: Failed to download resource "clamav"
Download failed: https://www.clamav.net/downloads/production/clamav-0.99.1.tar.gz

@chickymonkey

This comment has been minimized.

chickymonkey commented Jan 9, 2018

sudo chown clamav /usr/local/var/run/clamav/
sudo chmod 775 /usr/local/var/run/clamav/

@Henrietta1989

This comment has been minimized.

Henrietta1989 commented Apr 7, 2018

I'm planning to install Clamav to High Sierra soon.

Could some one combine all these instructions to one post which works? Thanks!

@kamok

This comment has been minimized.

kamok commented Apr 13, 2018

Add this in your bash_profile if you are getting a can't find command clamd

export PATH=/usr/local/sbin:$PATH

Also, the main post's location for clamd.conf is wrong. Put it inside the clamv directory one directory in.

@freayd

This comment has been minimized.

freayd commented Nov 18, 2018

Hi folks. I created an install script that does all the job:

  • Install ClamAV from Homebrew.
  • Setup all the required ClamAV files (including configuration).
  • Create two daemons to automatically run clamd and freshclam.

https://github.com/freayd/clamav-tools/blob/master/install-on-macos.sh

Let me know if there's anything wrong and I'll fix it. Maybe this script could actually be directly integrated directly into the Homebrew package?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment