问题
pecl install cassandra
produces an error:
configure: error: Unable to load libcassandra
ERROR: `/tmp/pear/temp/cassandra/configure' failed
This error message is subject of another question here on SO, but has not been resolved: Installing php datastax driver on ubuntu
Can anybody help?
回答1:
You are missing cassandra C++ driver. I have run into the same issue on Ubuntu 14.04. I have done the following and it worked for me:
Prerequisites (Ubuntu 14.04):
sudo apt-get install php-pear php5-dev libgmp-dev libpcre3-dev g++ make cmake libssl-dev openssl
Download the following packages:
wget http://downloads.datastax.com/cpp-driver/ubuntu/16.04/dependenices/libuv/v1.8.0/libuv_1.8.0-1_amd64.deb
wget http://downloads.datastax.com/cpp-driver/ubuntu/16.04/dependenices/libuv/v1.8.0/libuv-dev_1.8.0-1_amd64.deb
wget http://downloads.datastax.com/cpp-driver/ubuntu/16.04/v2.4.1/cassandra-cpp-driver_2.4.1-1_amd64.deb
wget http://downloads.datastax.com/cpp-driver/ubuntu/16.04/v2.4.1/cassandra-cpp-driver-dev_2.4.1-1_amd64.deb
Install them in this order using dpkg:
sudo dpkg -i libuv_1.8.0-1_amd64.deb
sudo dpkg -i libuv-dev_1.8.0-1_amd64.deb
sudo dpkg -i cassandra-cpp-driver-dev_2.4.1-1_amd64.deb
sudo dpkg -i cassandra-cpp-driver_2.4.1-1_amd64.deb
You should be able to install cassandra using pecl.
Don't forget to add extension=cassandra.so
to your php.ini file and restart php process.
Based on an answer in the discussion you linked before.
回答2:
This is how I got it to work (on debian):
sudo apt-get update
sudo apt-get install -y g++ git make cmake clang libssl-dev libgmp-dev php5-cgi php5-fpm php5 php5-dev openssl libpcre3-dev
sudo apt-get install libc6
sudo apt-get -f install
sudo curl http://downloads.datastax.com/cpp-driver/ubuntu/14.04/libuv_1.7.5-1_amd64.deb > /var/www/html/libuv_1.7.5-1_amd64.deb
sudo curl http://downloads.datastax.com/cpp-driver/ubuntu/14.04/libuv-dev_1.7.5-1_amd64.deb > /var/www/html/libuv-dev_1.7.5-1_amd64.deb
sudo curl http://downloads.datastax.com/cpp-driver/ubuntu/14.04/cassandra-cpp-driver_2.0.1-1_amd64.deb > cassandra-cpp-driver_2.0.1-1_amd64.deb
sudo curl http://downloads.datastax.com/cpp-driver/ubuntu/14.04/cassandra-cpp-driver-dev_2.0.1-1_amd64.deb > cassandra-cpp-driver-dev_2.0.1-1_amd64.deb
sudo dpkg -i libuv_1.7.5-1_amd64.deb
sudo dpkg -i libuv-dev_1.7.5-1_amd64.deb
sudo dpkg -i cassandra-cpp-driver_2.0.1-1_amd64.deb
sudo dpkg -i cassandra-cpp-driver-dev_2.0.1-1_amd64.deb
sudo pecl install cassandra
回答3:
I tried installing cassandra driver for php on Ubuntu 14.04.1 LTS for PHP 5.5.9 using php-driver and cpp-driver as follows,
sudo apt-get install g++ clang make cmake libuv-dev libssl-dev git;
git clone https://github.com/datastax/cpp-driver.git
mkdir cpp-driver/build
cd cpp-driver/build
cmake ..
make
and then,
sudo apt-get install libgmp-dev php5 php5-dev openssl libpcre3-dev
pecl install cassandra
But got an error,
checking for supported DataStax C/C++ driver version... nawk: cannot open /include/cassandra.h (No such file or directory)
configure: error: not supported. Driver version 2.4.2+ required (found )
ERROR: /tmp/pear/temp/cassandra/configure' failed
after coping,
cp cpp-driver/include/cassandra.h /usr/include/
again got another one,
checking for cass_cluster_new in -lcassandra... no
configure: error: Unable to load libcassandra
ERROR: /tmp/pear/temp/cassandra/configure' failed
After doing lot of research, I got following simple solution,
sudo wget http://downloads.datastax.com/cpp-driver/ubuntu/14.04/dependencies/libuv/v1.8.0/libuv_1.8.0-1_amd64.deb
sudo wget http://downloads.datastax.com/cpp-driver/ubuntu/14.04/dependencies/libuv/v1.8.0/libuv-dev_1.8.0-1_amd64.deb
sudo wget http://downloads.datastax.com/cpp-driver/ubuntu/14.04/cassandra/v2.5.0/cassandra-cpp-driver-dev_2.5.0-1_amd64.deb
sudo wget http://downloads.datastax.com/cpp-driver/ubuntu/14.04/cassandra/v2.5.0/cassandra-cpp-driver_2.5.0-1_amd64.deb
sudo dpkg -i libuv_1.8.0-1_amd64.deb
sudo dpkg -i libuv-dev_1.8.0-1_amd64.deb
sudo dpkg -i cassandra-cpp-driver-dev_2.5.0-1_amd64.deb
sudo dpkg -i cassandra-cpp-driver_2.5.0-1_amd64.deb
Then just copy and enable extension,
sudo vim /etc/php5/mods-available/cassandra.ini
extension=cassandra.so;
php5enmod cassandra
回答4:
For CentOS 7. Installation steps are:
sudo yum update
sudo yum install automake cmake gcc gcc-c++ git libtool openssl-devel wget gmp gmp-devel boost php-devel pcre-devel git
pushd /tmp
wget http://dist.libuv.org/dist/v1.8.0/libuv-v1.8.0.tar.gz
tar xzf libuv-v1.8.0.tar.gz
pushd libuv-v1.8.0
sh autogen.sh
./configure
sudo make install
popd
popd
sudo curl http://downloads.datastax.com/cpp-driver/centos/7/dependencies/libuv/v1.8.0/libuv-1.8.0-1.el7.centos.x86_64.rpm
sudo curl http://downloads.datastax.com/cpp-driver/centos/7/dependencies/libuv/v1.8.0/libuv-devel-1.8.0-1.el7.centos.x86_64.rpm
sudo curl http://downloads.datastax.com/cpp-driver/centos/7/cassandra/v2.4.3/cassandra-cpp-driver-2.4.3-1.el7.centos.x86_64.rpm
sudo curl http://downloads.datastax.com/cpp-driver/centos/7/cassandra/v2.4.3/cassandra-cpp-driver-devel-2.4.3-1.el7.centos.x86_64.rpm
sudo rpm -ivh libuv-1.8.0-1.el7.centos.x86_64.rpm
sudo rpm -ivh libuv-devel-1.8.0-1.el7.centos.x86_64.rpm
sudo rpm -ivh cassandra-cpp-driver-2.4.3-1.el7.centos.x86_64.rpm
sudo rpm -ivh cassandra-cpp-driver-devel-2.4.3-1.el7.centos.x86_64.rpm
sudo yum update
sudo pecl install cassandra
sudo yum update
回答5:
For ubuntu 14.04: Installation steps are:
sudo apt-get install php-pear php5-dev libgmp-dev libpcre3-dev g++ make cmake libssl-dev openssl
wget downloads.datastax.com/cpp-driver/ubuntu/14.04/dependencies/libuv/v1.8.0/libuv_1.8.0-1_amd64.deb
wget downloads.datastax.com/cpp-driver/ubuntu/14.04/dependencies/libuv/v1.8.0/libuv-dev_1.8.0-1_amd64.deb
wget downloads.datastax.com/cpp-driver/ubuntu/14.04/cassandra/v2.4.2/cassandra-cpp-driver_2.4.2-1_amd64.deb
wget downloads.datastax.com/cpp-driver/ubuntu/14.04/cassandra/v2.4.2/cassandra-cpp-driver-dev_2.4.2-1_amd64.deb
sudo dpkg -i libuv_1.8.0-1_amd64.deb
sudo dpkg -i libuv-dev_1.8.0-1_amd64.deb
sudo dpkg -i cassandra-cpp-driver_2.4.2-1_amd64.deb
sudo dpkg -i cassandra-cpp-driver-dev_2.4.2-1_amd64.deb
pecl install cassandra
ADD extension=cassandra.so in php.ini
restart the PHP process
回答6:
For the Docker's official PHP machine:
cd /tmp
apt-get install php-pear php5-dev libgmp-dev libpcre3-dev g++ make cmake libssl-dev openssl
php -r '$files = ["http://downloads.datastax.com/cpp-driver/ubuntu/14.04/dependencies/libuv/v1.8.0/libuv_1.8.0-1_amd64.deb", "http://downloads.datastax.com/cpp-driver/ubuntu/14.04/dependencies/libuv/v1.8.0/libuv-dev_1.8.0-1_amd64.deb", "http://downloads.datastax.com/cpp-driver/ubuntu/14.04/v2.3.0/cassandra-cpp-driver_2.3.0-1_amd64.deb", "http://downloads.datastax.com/cpp-driver/ubuntu/14.04/v2.3.0/cassandra-cpp-driver-dev_2.3.0-1_amd64.deb"]; foreach($files as $file) { copy($file, basename($file)); }'
dpkg -i libuv_1.8.0-1_amd64.deb
dpkg -i libuv-dev_1.8.0-1_amd64.deb
dpkg -i cassandra-cpp-driver_2.3.0-1_amd64.deb
dpkg -i cassandra-cpp-driver-dev_2.3.0-1_amd64.deb
pecl install cassandra
echo 'extension=cassandra.so' > /usr/local/etc/php/conf.d/php-ext-cassandra.ini
Then restart the container (docker-compose restart ~~image~fpm~~
).
回答7:
This works for me on Debian Jessie
apt-get remove libuv0.10-dev
git clone https://github.com/libuv/libuv.git
cd libuv
git reset --hard v1.19.1
sh autogen.sh
./configure
make
make check
sudo make install
git clone https://github.com/datastax/php-driver.git
cd php-driver
git submodule update --init
cd ext
./install.sh
vi /etc/php5/cli/php.ini
Add extension=cassandra.so
php -i | grep cassandra
回答8:
for cantos Casandra 2.4.3 was deprecated, I updated perivious post:
sudo yum update
sudo yum install automake cmake gcc gcc-c++ git libtool openssl-devel wget gmp gmp-devel boost php-devel pcre-devel git
pushd /tmp
wget http://dist.libuv.org/dist/v1.8.0/libuv-v1.8.0.tar.gz
tar xzf libuv-v1.8.0.tar.gz
pushd libuv-v1.8.0
sh autogen.sh
./configure
sudo make install
popd
popd
sudo wget http://downloads.datastax.com/cpp-driver/centos/7/dependencies/libuv/v1.8.0/libuv-1.8.0-1.el7.centos.x86_64.rpm
sudo wget http://downloads.datastax.com/cpp-driver/centos/7/dependencies/libuv/v1.8.0/libuv-devel-1.8.0-1.el7.centos.x86_64.rpm
sudo wget https://downloads.datastax.com/cpp-driver/centos/7/cassandra/v2.8.0/cassandra-cpp-driver-2.8.0-1.el7.centos.x86_64.rpm
sudo wget https://downloads.datastax.com/cpp-driver/centos/7/cassandra/v2.8.0/cassandra-cpp-driver-devel-2.8.0-1.el7.centos.x86_64.rpm
sudo rpm -ivh libuv-1.8.0-1.el7.centos.x86_64.rpm
sudo rpm -ivh libuv-devel-1.8.0-1.el7.centos.x86_64.rpm
sudo rpm -ivh cassandra-cpp-driver-2.8.0-1.el7.centos.x86_64.rpm
sudo rpm -ivh cassandra-cpp-driver-devel-2.8.0-1.el7.centos.x86_64.rpm
sudo yum update
sudo pecl install cassandra
sudo yum update
来源:https://stackoverflow.com/questions/32997871/pecl-install-cassandra-throws-error-unable-to-load-libcassandra