I have installed clamav, clamav-devel, and php-clamav. Having done so, I can access the functions (e.g. cl_scanfile()) in my php scripts.
It suddenly stopped working after a yum update, but I cannot figure out why.
PHP Version 5.5.31
Centos 7: 3.10.0-327.4.5.el7.x86_64 #1 SMP Mon Jan 25 22:07:14 UTC 2016 x86_64
Apache 2.0 Handler
clamav itself still works (from the linux command line)
phpinfo.php reports that /etc/php.d/php-clamav.ini has been processed as an .ini file
There is no separate php-clamav section in phpinfo.php (but I don't know if there ever was)
I tried recompiling from the php-clamav_0.15.8.tar.gz file:
tar -xvzf php-clamav_0.15.8.tar.gz
cd php-clamav-0.15.8
phpize
./configure
make
reports that libraries have been installed in /usr/php-clamav/php-clamav-0.15.8/modules
make install
Installing shared extensions: /usr/lib64/php/modules/
/etc/php.d/php-clamav.ini contains:
; enable extension for php-clamav
; created by Jose
extension=/usr/php-clamav/php-clamav-0.15.8/modules/clamav.so
; load antivirus db on startup rather than on every scan
;clamav.load_db_on_startup=1
... and the clamav.so is in fact there (and newly created, or at least newly touched)
I have restarted apache:
service httpd restart
and still the php-clamav functions are not available.
Where else should I look?
Jose
Oh - one other thing - during the installation I got the message;
You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
What does this mean? What is "regenerating PHP parsers" and why might I want to do this?
WORKAROUND:
php -i also shows the lines:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/clamav.so' - libclamav.so.6: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/php-clamav/php-clamav-0.15.8/modules/clamav.so' - libclamav.so.6: cannot open shared object file: No such file or directory in Unknown on line 0
Sure enough, there is no libclamav.so.6, but there is a libclamav.so.7 (which points to libclamav.so.7.1.1) and a libclamav.so (which points to the same libclamav.so.7.1.1)
libclamav.so.7.1.1 exists.
So... it seems that php-clamav is trying to load an older version of the libclamav shared object.
clamav had been updated (that's when it broke), but php-clamav has not changed to match.
SO... I added a symbolic link: libclamav.so.6 which points to the existing libclamav.so.7.1.1
Now the functions are available. However, not knowing the changes between the different libclamav shared objects, I don't really know if this actually works, only that it appears to work. It is certainly possible that the new libclamav.so.7.1.1 introduces an incompatibility of which I am not aware.
Jose
Last edit: Anonymous 2016-02-05
Hi,
Thanks for your report and debug.
I've look the new clamav 0.99 version are a libclamav version 7.
I think that need to compile php-clamav after this new clamav version are installed.
Thanks.
Thanks - fixed!
I recompiled and now it works. Odd... I had recompiled before and that did not fix it. However this time I cleaned out the old stuff before recompiling. Perhaps that was the problem.
Three questions:
QUESTION 1: the
./configure
command gave the warning:
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
What is regenerating PHP parsers, and why might I want to do this?
QUESTION 2: What does "make test" do? I ran it and got the following, indicating "no tests were run":
root@communion: /usr/php-clamav/php-clamav-0.15.8:# make test
Build complete.
Don't forget to run 'make test'.
=====================================================================
PHP : /usr/bin/php
PHP_SAPI : cli
PHP_VERSION : 5.5.31
ZEND_VERSION: 2.5.0
PHP_OS : Linux - Linux communion 3.10.0-327.4.5.el7.x86_64 #1 SMP Mon Jan 25 22:07:14 UTC 2016 x86_64
INI actual : /usr/php-clamav/php-clamav-0.15.8/tmp-php.ini
More .INIs :
CWD : /usr/php-clamav/php-clamav-0.15.8
Extra dirs :
VALGRIND : Not used
=====================================================================
TIME START 2016-02-06 10:19:21
=====================================================================
No tests were run.
QUESTION 3: Will recompiling be needed every time clamav updates?
Thanks for your help, and for writing this great program!
Jose
I have the same problem
Error:
Starting php-fpm56: [10-Dec-2016 13:20:32] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/php56/lib/php/extensions/clamav.so' - libclamav.so.7: cannot open shared object file: No such file or directory in Unknown on line 0
please help me to fix this
Thanks