Create a gist now

Instantly share code, notes, and snippets.

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

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
TTL: 1694
Software version from DNS: 0.98.1
Trying to download (IP:
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)

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.

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

Thank you! This saved me a lot of time.

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

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

rackoh commented Oct 6, 2016

after installing clamav, clamd is giving error

clamd: command not found

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

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

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 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

curl: (22) The requested URL returned error: 403
Error: Failed to download resource "clamav"
Download failed:

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

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