Install php-clamav on CentOS 6

Earlier today I posted how to install ClamAV on CentOS 6. Along with ClamAV, you may also wish to use the php-clamav tools, as well. This is a quick guide of what I did to add that, as well.

First, you may need a few tools I, myself, were missing on my server. To compile it, I had to install php-devel, openssl, and openssl-devel. We also need clamav-devel to compile php-clamav with. To determine what I needed for php-devel, I did:

yum list installed | grep php

This told me I needed the php56w version, as that is what my server is running (PHP 5.6). So, to be able to add php-clamav, I did the following:

yum install php56w-devel openssl openssl-devel clamav-devel
service httpd restart

Next, download the source of the php-clamav tool. This can be found here:

Now we need to extract the source and compile it.

tar zxvf php-clamav_0.15.8.tar.gz
cd php-clamav-0.15.8/
make install

If all is well, you should have a file like the following:


If you get make errors, check and see where it failed. You may have dependencies that are missing. This was the case for me. I was missing openssl and openssl-devel, which is needed by the make call.

Now you need to tell PHP to use this file.

vi /etc/php.ini



in the ; Dynamic Extensions ; section of the file. It can really go anywhere in the file (I believe). I just like to put it where it’s described.

Finally, restart Apache:

service httpd restart

Now, you should have access to the various php-clamav functions within your scripts.

Hope this helps!

Posted in Linux, PHP Tagged with: , ,