Skip to content

Instantly share code, notes, and snippets.

@Uchean
Created December 9, 2015 23:36
Show Gist options
  • Star 92 You must be signed in to star a gist
  • Fork 23 You must be signed in to fork a gist
  • Save Uchean/4fdc875e557014c3a34e to your computer and use it in GitHub Desktop.
Save Uchean/4fdc875e557014c3a34e 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 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
Copy link

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

Thank you! This saved me a lot of time.

@LucasMW
Copy link

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

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

shrop commented Sep 28, 2016

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

@rackoh
Copy link

rackoh commented Oct 6, 2016

after installing clamav, clamd is giving error

clamd: command not found

@otheus
Copy link

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

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

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

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

@gagarine
Copy link

@flickerfly
Copy link

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

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

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

@Henrietta1989
Copy link

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

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

@kamok
Copy link

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

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?

@sijojlouis
Copy link

sijojlouis commented Dec 30, 2018

Here's notes (didn't try it though) on Installation on macOS X: https://www.clamav.net/documents/installation-on-macos-mac-os-x

@appleserveruser
Copy link

appleserveruser commented Feb 27, 2019

Interesting Thread that is helpful. However, I suppose I am among some that are attempting to keep the Apple server app version 5.6.3 alive a few more years while it still has useful features in it (newer versions are stripped of functionality). The main issue is updating Clamav to the latest version .101.1. I have found that homebrew, and MacPort are compilers that make installation easier (or supposed to be easier) but I cannot find how to remove the current clamav .99 version thats operating on the server. I used Macports which installed the new version but it does not over ride the current version or offer any advise of what is needed to switch the config files to use the fresh install. I am not a fluent unix command line operator but can somewhat do it if I have good instructions. Any advise or suggestions is appreciated.

@mumargoldev
Copy link

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.

worked for me. thanks

@futografia
Copy link

futografia commented May 16, 2019

Here's notes (didn't try it though) on Installation on macOS X: https://www.clamav.net/documents/installation-on-macos-mac-os-x

Working, clean instructions.

@Drallas
Copy link

Drallas commented Jun 14, 2019

Why can't you make a more user friendly installation method!?

@NikhilNanjappa-zz
Copy link

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.

This resolved my "clamd command not found" issue.

@vasanthsg
Copy link

Would appreciate updating the install procedure. Without reading the comments below, it couldn't have worked. @kamok Thank you for pointing the path export.

@MarkVLK
Copy link

MarkVLK commented Jun 24, 2020

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.

This resolved my "clamd command not found" issue.

By the way, if you're on macOS Catalina or higher and moved from bash to zsh, you'll need to use .zprofile instead of .bash_profile. See this StackOverflow question + answer for more details: https://stackoverflow.com/questions/56784894/macos-catalina-10-15beta-why-is-bash-profile-not-sourced-by-my-shell

@cmyk
Copy link

cmyk commented Jan 30, 2024

Terribly outdated instructions. My homebrew is installed in /opt/local

@cmyk
Copy link

cmyk commented Jan 31, 2024

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