Skip to content

Instantly share code, notes, and snippets.

@Uchean
Created December 9, 2015 23:36
Show Gist options
  • Select an option

  • Save Uchean/4fdc875e557014c3a34e to your computer and use it in GitHub Desktop.

Select an option

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

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

Thank you! This saved me a lot of time.

@LucasMW

LucasMW commented Sep 3, 2016

Copy link
Copy Markdown

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

Copy link
Copy Markdown

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

Copy link
Copy Markdown

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

@rackoh

rackoh commented Oct 6, 2016

Copy link
Copy Markdown

after installing clamav, clamd is giving error

clamd: command not found

@otheus

otheus commented Oct 16, 2016

Copy link
Copy Markdown

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

Copy link
Copy Markdown

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

Copy link
Copy Markdown

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

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

@gagarine

Copy link
Copy Markdown

@flickerfly

Copy link
Copy Markdown

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

BSBjorn commented Oct 31, 2017

Copy link
Copy Markdown

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

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

@Henrietta1989

Copy link
Copy Markdown

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

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

@kamok

kamok commented Apr 13, 2018

Copy link
Copy Markdown

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

freayd commented Nov 18, 2018

Copy link
Copy Markdown

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

sijojlouis commented Dec 30, 2018

Copy link
Copy Markdown

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

appleserveruser commented Feb 27, 2019

Copy link
Copy Markdown

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

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

futografia commented May 16, 2019

Copy link
Copy Markdown

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

Drallas commented Jun 14, 2019

Copy link
Copy Markdown

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

@NikhilNanjappa-zz

Copy link
Copy Markdown

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

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

MarkVLK commented Jun 24, 2020

Copy link
Copy Markdown

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

cmyk commented Jan 30, 2024

Copy link
Copy Markdown

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

@cmyk

cmyk commented Jan 31, 2024

Copy link
Copy Markdown

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