clamd error on Mountain Lion Server

On an install of OS X Server 10.8.5 Mountain Lion where mail services had not been used, I received the error from clamd “can’t open file or directory.”  There was no more information available in the /Library/Logs/Mail/clamav.log.

After a bunch of dead ends I was looking at the setup script (/Applications/Server.app/Contents/ServerRoot/System/Library/ServerSetup/CommonExtras/63-setup_clamav.sh) to find permissions for all items and stumbled across this:

# Set _clamav home to /var/clamav
`/usr/bin/dscl . -create /Users/_clamav NFSHomeDirectory /var/clamav`
`/usr/bin/dscl . -append /Groups/_amavisd GroupMembership _clamav`

Turns out /var/clamav didn’t exist!  Turned off Mail services and created the directory, set permissions, and fired it back up – no error.

I was root and already in /var so these commands are different from what I used, but they’re more universal and can be run directly after opening Terminal.

sudo mkdir /var/clamav

sudo chown _clamav:_clamav /var/clamav