How to install php-clamav

First download, build and install clamav. I found that Debian Squeeze’s clamav in the apt package was not detected by the php-clamav installation script.


tar -xvvf clamav-0.97.6.tar.gz
cd clamav-0.97.6
make install

Now download , build and install php-clamav

tar -xvvf php-clamav_0.15.7.tar.gz
cd php-clamav-0.15.7/
./configure --with-clamav
make install

Once installed, you need to enable php-clamav.

First edit the clamav configuration file:

emacs /usr/local/etc/clamd.conf

Read the file and set your options. At the bare minimum, you need to comment out this line:


So it reads this:


Now run clamscan and test that it works:

[[email protected]] /etc/php5/conf.d #clamdscan -V
ClamAV 0.97.6

If there’s an issue with the configuration, at this point it will notify you to correct it. If everything is alright, it will report the version.

Now you need to setup so that clamav php extension loads up whenever the web server is loaded.

Create a new text file in /etc/php5/conf.d/clamav.ini with the following content:

Now restart apache2 on the webserver and load a php file with the function phpinfo (assuming it is enabled on your server of course). You can confirm that the extension is loaded by the fact that phpinfo reports a whole new section for clamav (Just use the search option on the page).

You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.