This is not a big tutorial. Last week I just reinstalled Cassandra on my machine. I got many issues with PHP 7.0, Cassandra on Ubuntu 16.04.

PHP-CASSANDRA

Finally, I found a solution to solve those issues. You have already installed PHP(Lamp) and Cassandra. Right? Then, just install the PHP external packages for Cassandra and add the extension to the ‘php.ini’ file.

Let us start from using following commands. Open your Terminal. I hope you would be the root user.

sudo -s

then,

add-apt-repository ppa:ondrej/php

apt-get update apt-get install build-essential cmake git libpcre3-dev php7.0-dev

apt-get install libgmp-dev

apt-get install libssl-dev

We have to download and install libuv and Cassandra C++ packages.

You would get the latest versions of libuv and the Cassandra C++ drivers for the Ubuntu 16.04 from this directory.

Parent Directory

libuv packages

Cassandra-c++drivers

or

You can download and install latest versions of libuv and the Cassandra C++ drivers for the Ubuntu 16.04 using the following commands.

Installing downloaded packages

sudo dpkg -i libuv_1.16.1–1_amd64.deb

sudo dpkg -i libuv-dev_1.16.1–1_amd64.deb

sudo dpkg -i cassandra-cpp-driver_2.8.0–1_amd64.deb

sudo dpkg -i cassandra-cpp-driver-dev_2.8.0–1_amd64.deb

Then you can install the real PHP-Cassandra extension.

Installing PHP-Cassandra extension using PECL

pecl install cassandra

Enabling the PHP extension

To determine where the php.ini file is located on your system run the following command:

php -r "echo php_ini_loaded_file();"

Edit the php.ini file and add the following line to enable the extension:

; DataStax PHP Driver for Apache Cassandra

extension=cassandra.so

To verify the extension is being loaded the following command can be executed:

php -i | grep -A 10 "^cassandra$"

or

php -m

You can see like this

Cassandra Module

I hope you got it. Happy coding! Enjoy with Cassandra.