Install Cassandra PHP extension

Install Cassandra PHP extension

 

You might see the below errors while installing Cassandra PHP extension. Few dependencies should be installed before installing Cassandra PHP extension on your Linux server.

 

Error :

checking for __gmp_version in -lgmp... no
configure: error: Unable to load libgmp

checking for uv_version in -luv... no
configure: error: Unable to load libuv

dpkg: dependency problems prevent configuration of cassandra-cpp-driver:
cassandra-cpp-driver depends on libuv; however:
Package libuv is not installed.


 

Install the below packages to fix the above error. You can download cassandra c++ driver and libuv from datastax.com website.

http://downloads.datastax.com/cpp-driver/ubuntu/16.04/

1. Log into your Linux server via SSH as ‘root’ user OR login as any user with sudo privileges

2. Install the below dependencies using apt

 

apt-get install g++ make cmake libuv-dev libssl-dev libgmp-dev openssl libpcre3-dev git


 

3. Change to /usr/local/src directory after above installation is completed.

 

cd /usr/local/src


 

4. Download the below packages from datastax.com website using wget

 

wget https://downloads.datastax.com/cpp-driver/ubuntu/16.04/dependencies/libuv/v1.20.0/libuv_1.20.0-1_amd64.deb

wget https://downloads.datastax.com/cpp-driver/ubuntu/16.04/dependencies/libuv/v1.20.0/libuv-dev_1.20.0-1_amd64.deb

wget https://downloads.datastax.com/cpp-driver/ubuntu/16.04/cassandra/v2.7.0/cassandra-cpp-driver_2.7.0-1_amd64.deb

wget https://downloads.datastax.com/cpp-driver/ubuntu/16.04/cassandra/v2.7.0/cassandra-cpp-driver-dev_2.7.0-1_amd64.deb


 

5. Install the packages using dpkg command.

 

root@server:/usr/local/src# dpkg -i libuv_1.20.0-1_amd64.deb

root@server:/usr/local/src# dpkg -i libuv-dev_1.20.0-1_amd64.deb

root@server:/usr/local/src# dpkg -i cassandra-cpp-driver_2.7.0-1_amd64.deb

root@server:/usr/local/src# dpkg -i cassandra-cpp-driver-dev_2.7.0-1_amd64.deb


 

6. Run the command ‘pecl install cassandra’ to install Cassandra PHP extension.

 

root@server:/usr/local/src# pecl install cassandra


 

7. Check the path of your PHP configuration file

Run the command ‘php --ini’ OR ‘php -i | grep php.ini’ to find the location of your PHP configuration file.

8. Add the extension cassandra.so in your php configuration file

 

root@server:/usr/local/src# echo "extension=cassandra.so" >> /etc/php/7.0/cli/php.ini


 

9. Run the command ‘php -m | grep cassandra’ to make sure the extension is enabled

 

root@server:/usr/local/src# php -m | grep cassandra
cassandra