pecl install cassandra throws: "error: Unable to load libcassandra"

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.


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

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