问题
I need to install clamav to be used on php. How can I do it? I have tried to google how to install clamav, but most instructions either install clam av correctly, but not the php package, or missing dependencies, or similar problems.
回答1:
You just need to install ClamAV like normal (with the epel repo)...
yum install clamav
yum install clamav-devel
If you don't have EPEL you can get it from IUS community (if you want you can also grab the IUS repo and get the latest version of PHP) - thank the RackSpace engineers for this!
wget http://dl.iuscommunity.org/pub/ius/stable/CentOS/6/x86_64/epel-release-6-5.noarch.rpm
rpm -ivh epel-release-6-5.noarch.rpm
Then you download and install this library, which will handle all the hard things for you.
wget **the direct link you got**
tar -xvzf php-clamav_0.15.7.tar.gz
cd php-clamav-0.15.7
phpize
./configure
make
make install
Now add the extension to your /etc/php.ini
extension=/usr/lib64/php/modules/clamav.so
Remember to change the path to what was given to you by make install
then restart your Apache
service httpd restart
Make a file with the contents:
<?php
echo cl_info();
It should come up with something like this:
Now you should have access to all the library functions, you can now scan files like this:
$retcode = cl_scanfile($file, $virus_name);
if ($retcode === CL_VIRUS)
{
echo "Virus Detected! {$virus_name}";
}
Congratulations! You can find other functions here
来源:https://stackoverflow.com/questions/16658450/how-to-install-php-clamav-on-centos