Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

2 Answers 2

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):

    phpize
    ./configure --with-clamav
    make  
    cp modules/clamav.so /usr/local/lib/php/extensions/
    (restart Apache)
    service httpd restart
    
share|improve this answer
1  
Thanks, I could install it without errors, but by downloading clamav (clamav.net/lang/en/download/sources) + 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: extension=clamav.so 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.

Preparation

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:

wget http://downloads.sourceforge.net/clamav/clamav-0.98.4.tar.gz
tar xzf clamav-0.98.4.tar.gz
cd clamav-0.98.4
./configure
make
make install
ldconfig

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:

freshclam

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:

wget https://launchpad.net/php-clamav/trunk/0.15.7/+download/php-clamav_0.15.7.tar.gz
tar xzf php-clamav_0.15.7.tar.gz
cd php-clamav_0.15.7
phpize
./configure --with-clamav
make
make install

Install into Apache and restart:

echo "extension=clamav.so" > /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

 
discard

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.