Skip to content

Instantly share code, notes, and snippets.

@mendozao
Forked from Uchean/clamav-mac.md
Last active September 11, 2024 00:50
Show Gist options
  • Save mendozao/3ea393b91f23a813650baab9964425b9 to your computer and use it in GitHub Desktop.
Save mendozao/3ea393b91f23a813650baab9964425b9 to your computer and use it in GitHub Desktop.
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 daemon, you'll need a copy of the ClamAV databases.

Inside /your/location/to/brew/etc/clamav, you'll see 2 files:

  1. freshclam.conf.sample
  2. clamd.conf.sample

Create copies of the samples:

$ cp freshclam.conf.sample freshclam.conf && cp clamd.conf.sample clamd.conf

Open up freshclam.conf, comment out "Example" from line 8, and make sure

DatabaseMirror database.clamav.net

is enabled. Save your changes.

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

Open up clamd.conf, and

  1. Comment: "Example" from line 8
  2. Uncomment: LocalSocket /tmp/clamd.socket from line 85
  3. Save your changes

Next, let's look for the location of clamd by running: $ brew ls clamav

You should see the following:

/your/location/to/brew/Cellar/clamav/0.99.2_1/bin/clamav-config
/your/location/to/brew/Cellar/clamav/0.99.2_1/bin/clambc
/your/location/to/brew/Cellar/clamav/0.99.2_1/bin/clamconf
/your/location/to/brew/Cellar/clamav/0.99.2_1/bin/clamdscan
/your/location/to/brew/Cellar/clamav/0.99.2_1/bin/clamdtop
/your/location/to/brew/Cellar/clamav/0.99.2_1/bin/clamscan
/your/location/to/brew/Cellar/clamav/0.99.2_1/bin/clamsubmit
/your/location/to/brew/Cellar/clamav/0.99.2_1/bin/freshclam
/your/location/to/brew/Cellar/clamav/0.99.2_1/bin/sigtool
/your/location/to/brew/Cellar/clamav/0.99.2_1/include/clamav.h
/your/location/to/brew/Cellar/clamav/0.99.2_1/lib/libclamav.7.dylib
/your/location/to/brew/Cellar/clamav/0.99.2_1/lib/libclamunrar.7.dylib
/your/location/to/brew/Cellar/clamav/0.99.2_1/lib/pkgconfig/libclamav.pc
/your/location/to/brew/Cellar/clamav/0.99.2_1/lib/ (4 other files)
/your/location/to/brew/Cellar/clamav/0.99.2_1/sbin/clamd  <------------- clamd location is here
/your/location/to/brew/Cellar/clamav/0.99.2_1/share/clamav/ (4 files)
/your/location/to/brew/Cellar/clamav/0.99.2_1/share/man/ (13 files)

To start the clamd daemon, run the following:

$ /your/location/to/brew/Cellar/clamav/0.99.2_1/sbin/clamd

You should now be able to scan a file by doing:

$ clamdscan /some/location/myfile.txt
@remino
Copy link

remino commented Aug 13, 2023

It got merged! brew services start clamav now works. Or you may want to ensure it runs as root so it can scan the whole file system and start correctly on system boot with sudo brew services start clamav.

@sdasthagir
Copy link

Great instructions. Thank you @mendozao

@jcpyun @bennettierney - do I know you guys?

@jcpyun
Copy link

jcpyun commented Nov 15, 2023

What is going on gamers? I'm back here again
asuhhhhh @bennettierney @sdasthagir @mendozao

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