Monday, November 29, 2010

install clamAV on httpd server

We need to check following
php-devel and clamav-devel.

To check for the software, use the commands below:

CODE
rpm -q php-devel


CODE
rpm -q clamav-devel


If nothing is returned from either rpm command, you will need to install the devel for the appropriate version.
If not installed the php-devel and clamav-devel install using yum
like

CODE
yum install php-devel

extract the library

CODE
tar xvzf php-clamavlib-0.12a.tar.gz

CODE
cd php-clamav-0.1

CODE
phpize

CODE
./configure --with-clamav

CODE
make

CODE
cp modules/clamav.so /usr/lib/php/modules

Note: /usr/lib/php/modules is my modules directory. Your module directory may be different. Search /etc/php.ini for extension_dir to get yours.

Edit /etc/php.ini (Make sure you make a backup!)
Add the following under the "Dynamic Extensions" section:

CODE
extension=clamav.so



[clamav]

clamav.dbpath="/var/clamav"

clamav.maxreclevel=0

clamav.maxfiles=0

clamav.archivememlim=0

clamav.maxfilesize=0

clamav.maxratio=0

Note: My clamav.dbpath may be different than yours. Do a simple locate main.cvd for the db directory.

Test to see if it works:
[PHP] echo cl_info() . "
";

$file = "/tmp/eicar.com";
cl_scanfile_ex($file, CL_SCAN_STDOPT, $virus, $retcode);
if ($retcode == CL_VIRUS)
echo $file . " returns: " . cl_pretcode($retcode) . " virus name: " . $virus . "
";
else
echo $file . " returns: " . cl_pretcode($retcode) . "
";
?>[/PHP]

Go to http://www.phpclamavlib.org/ for more information on the functions included with this module.

Good luck!

No comments: