Create a gist now

Instantly share code, notes, and snippets.

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

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

Thank you! This saved me a lot of time.

@LucasMW
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
fschroder commented Sep 8, 2016 edited

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
shrop commented Sep 28, 2016

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

@rackoh
rackoh commented Oct 6, 2016

after installing clamav, clamd is giving error

clamd: command not found

@otheus
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
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
LostAccount commented Jan 25, 2017 edited

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 documentation needs updating as it's been mentioned in almost all of the comments above.

@flickerfly

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.

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