Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to automatically scan uploaded files for viruses with php. There was an extension called php-clamavlib in earlier versions of ubuntu, but on Natty I get

E: Unable to locate package php5-clamavlib

Isn't there any extension anymore? What could I do to archive this?

share|improve this question
up vote 2 down vote accepted
  • Please download the latest php-clamav tarball from Launchpad.
  • Install php5-dev, clamav if you haven't already with sudo apt-get
  • Extract the tarball, cd into the php-clamav-xxxx directory, and follow these steps to install the php-clamav module (adapted from INSTALL):

    ./configure --with-clamav
    cp modules/ /usr/local/lib/php/extensions/
    (restart Apache)
    service httpd restart
share|improve this answer
Thanks, I could install it without errors, but by downloading clamav ( + configure + make + make install. Guess apt-get install clamav doesn't install a version thats up-to-date enough. I couldn't get the extension work yet but that's maybe another question. – 32bitfloat Jul 21 '12 at 12:51
I had to uninstall the Ubuntu version of ClamAV then install the downloaded version linked above, followed by php-clamav. Is there a reason this has been dropped from Aptitude? – Marcus Downing Oct 10 '13 at 10:27
The extension folder above was wrong as well - you can find where the extensions are on your system by running php-config --extension-dir. – Marcus Downing Oct 10 '13 at 10:28
I also had to add a file to /etc/php5/apache2/conf.d with the contents: to enable the extension. – Marcus Downing Oct 10 '13 at 10:34

Between izx's answer, 32bitfloat's comment and a bit of googling, I got this working (on Ubuntu 12.04 LTS). Here's exactly what I had to do. All these commands are as root, and some details may be different on your setup.


First, clear out any traces of existing ClamAV:

aptitude install zlib1g-dev php5-dev
aptitude purge clamav clamav-base clamav-data clamav-docs clamav-freshclam libclamav6

Install ClamAV

Download the latest ClamAV, make and install it:

tar xzf clamav-0.98.4.tar.gz
cd clamav-0.98.4
make install

Make freshclam work and run it:

useradd clamav
mkdir /usr/local/share/clamav
chown clamav /usr/local/share/clamav
cp /usr/local/etc/freshclam.conf.sample /usr/local/etc/freshclam.conf

Edit the file /usr/local/etc/freshclam.conf and comment out the line that says Example. Then update:


If that ran successfully, test it works by scanning a file:

clamscan somefile

Install PHP-ClamAV

Download the latest PHP-ClamAV, make and install it:

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

Install into Apache and restart:

echo "" > /etc/php5/conf.d/clamav.ini
service apache2 restart

I hope that lot's useful to somebody. I really wish php-clamav was still supported on Aptitude. It would be far nicer than the above.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.