Skip to content

Instantly share code, notes, and snippets.

Last active June 10, 2024 15:36
Show Gist options
  • Save gagarine/9168c1b7e4b5f55cb3254582e30d808e to your computer and use it in GitHub Desktop.
Save gagarine/9168c1b7e4b5f55cb3254582e30d808e to your computer and use it in GitHub Desktop.
Howto Install clamav on OSX with brew

Howto Install clamav on OSX with brew

Note: on legacy intel system the path may be /usr/local/etc/clamav instead of /opt/homebrew/etc/clamav/

$ brew install clamav
$ cd /opt/homebrew/etc/clamav/
$ cp freshclam.conf.sample freshclam.conf

Open freshclam.conf and comment the "Example" (in new version it may be "FooClam") line:

# Comment or remove the line below.
# Example

Update database:

 $ freshclam

Run scan on all your files:

$ clamscan -r --bell -i /
Copy link

Looks like line 1 should be:

$ brew install clamav

Copy link

I had to set "DatabaseDirectory /usr/local/homebrew/var/lib/clamav/" in both


and then
sudo chown _clamav /usr/local/homebrew/var/lib/clamav/

Copy link

gagarine commented Feb 26, 2017

@flickerfly you shouldn't have to use sudo with brew package.

@lucascantor thanks I fixed this typo.

Copy link

Thank you, this helped!

Copy link

This was very helpful, many thanks.

The initial scan takes forever.

I have an 1 TB drive, running on macOS Sierra 10.12.6.

Copy link

hanssep commented Oct 29, 2017

brew link clamav fails on macOS High Sierra.

Had to run following commands to get ClamAV working:
sudo mkdir /usr/local/sbin
sudo chown -R $(whoami) $(brew --prefix)/* (standard brew fix does not work anymore on OS X 10.13)
brew link clamav

Copy link

ghost commented May 28, 2018

The OP worked as is for me, when the "Example" was changed to "FooClam" or similar (Anything =/= Example).
No other changes made to freschclam.conf.

Why is it the first time I had to install Clamav with such effort, and with brew?

All the other versions till Sierra were nicely installed without any need to configure with a nice UI and reporting to console.

Copy link

ghost commented Oct 24, 2018

thanks @flickerfly !

Copy link

Thank you!

Copy link

ghost commented Sep 4, 2019

By default the database dir is /usr/local/share/clamav/, it is symlinked to Cellar/... and get cleared on update. It might be a good idea to change DatabaseDirectory to /usr/local/var/lib/clamav in freshclam.conf & clamd.conf.

Copy link

for Homebrew 2.2.2 on macOS 10.14.6 I found clamav symlink at

Copy link

BenBao93 commented May 5, 2020

There seems to be an error with version 0.102.2 on macOs 10.15.4, I get the same error as below on two machines with fresh install of clamav via homebrew:

bytecode database available for download (remote version: 331)
Time: 0.4s, ETA: 0.0s [=============================>] 289.44KiB/289.44KiB
Testing database: '/usr/local/var/lib/clamav/tmp.b4247/clamav-7fa84ca4faf4b1f913f1a8f88d439f21.tmp-bytecode.cvd' ...
ERROR: Database load killed by signal 11
ERROR: Database test FAILED.
ERROR: Unexpected error when attempting to update database: bytecode
WARNING: fc_update_databases: fc_update_database failed: Test failed (8)
ERROR: Database update process failed: Test failed (8)
ERROR: Update failed

Copy link

I am having problems to stop the ClamAV service in macOs 10.15.4. The process is running as you can see.

** 0 119 1 0 4:09PM ?? 0:33.27 /usr/local/sbin/clamd --foreground**

But when I try top stop it I get this error:

$ /usr/local/sbin/clamd stop
ERROR: LOCAL: Socket file /usr/local/var/run/clamav/clamd.sock is in use by another process.

Do I have to change something in the socket file?

Copy link

kunthar commented Feb 6, 2021

do yourself a favor. switch to macports.

Copy link

paulterinho commented Feb 25, 2021

@gagarine: Great instructions. Thanks so much for posting this. It's working great for me.

Copy link

tomasi-o commented May 28, 2021

do yourself a favor. switch to macports.

please don't. Installation via homebrew was so much easier than via macports where I had to chown multiple files to get clamav up and running.

Copy link

@tomasi-o actually, I agree with kunthar, macports is much more stable as a package manager. A particular port/package may have a bug, but the package manager is better for me. I do not use brew anymore.

Copy link

Thanks @gagarine

Copy link

Jarrid commented Jul 29, 2022

minor update - the clam conf files are now located at /opt/homebrew/etc/clamav/ after installing with homebrew.

Copy link

do you guys find the socket file that should be generated after installing clamav. I can not find one. help me :)

Copy link

This worked!!!!!!!!!!!!

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