Reputation: 2479
I've done the installation process as following:
System
PHP 7.0.5-1~dotdeb+8.1 (cli) ( NTS )
Debian 8
Nginx 1.8.1
Laravel 5.2
Java Installation
mkdir -p /usr/lib/jvm
wget URL to Oraclesite
mv mv jdk-8u77-linux-x64.tar.gz\?... jdk-8u77-linux-x64.tar.gz
tar xzf jdk-8u77-linux-x64.tar.gz
rm jdk-8u77-linux-x64.tar.gz
update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.8.0_version/bin/java" 1
update-alternatives --set java /usr/lib/jvm/jdk1.8.0_version/bin/java
Install needed packages
apt install cmake automake libtool git php7.0-dev libgmp-dev libssl-dev
Libuv Installation
cd /tmp
wget http://dist.libuv.org/dist/v1.7.5/libuv-v1.7.5.tar.gz
tar xzf libuv-v1.7.5.tar.gz
rm libuv-v1.9.0.tar.gz
cd libuv-v1.7.5
sh autogen.sh
./configure
make
make install
ldconfig
Installation Cassandra Datatrax
echo "deb http://debian.datastax.com/community stable main" | sudo tee -a /etc/apt/sources.list.d/cassandra.sources.list
curl -L http://debian.datastax.com/debian/repo_key | sudo apt-key add -
apt install cassandra dsc30
Check services
service cassandra status
cassandra.service - LSB: distributed storage system for structured data Loaded: loaded (/etc/init.d/cassandra) Active: active (running) since Mon 2016-04-11 01:11:04 CEST; 19min ago Process: 506 ExecStart=/etc/init.d/cassandra start (code=exited, status=0/SUCCESS) CGroup: /system.slice/cassandra.service
nodetool status
Datacenter: datacenter1 ======================= Status=Up/Down |/ State=Normal/Leaving/Joining/Moving -- Address Load Tokens Owns (effective) Host ID Rack UN 127.0.0.1 139.06 KB 256 100.0%
1ab0e99a-41a5-4007-b9ca-de58dc88e318 rack1
cqlsh
Connected to Test Cluster at 127.0.0.1:9042. [cqlsh 5.0.1 | Cassandra 3.0.4 | CQL spec 3.4.0 | Native protocol v4] Use HELP for help.
Installation php-driver (PECL Installation isn't working. I think it's because of only php7 setup)
git clone https://github.com/datastax/php-driver.git
cd php-driver
git submodule update --init
cd ext
./install.sh
make test -> all tests passed
Add Driver to PHP Extensions
echo -e "; DataStax PHP Driver\nextension=cassandra.so" >> /etc/php/7.0/cli/php.ini
// UPDATE - added extension to fpm/php.ini file.
echo -e "; DataStax PHP Driver\nextension=cassandra.so" >> /etc/php/7.0/fpm/php.ini
Restart nginx and php7.0-fpm
service nginx restart
service php7.0-fpm restart
Question:
If I wanna use the following code it says me class Cassandra not found. Webpage: https://github.com/datastax/php-driver#datastax-php-driver-for-apache-cassandra
$cluster = Cassandra::cluster()->build();
Thank you for helping.
Upvotes: 1
Views: 1712
Reputation: 2479
UPDATE 1
When I execute the following 2 commands I get the following two results, which looks quite successful.
php -m | grep cassandra
cassandra
php -i | grep -A 10 "^cassandra$"
cassandra
Cassandra support => enabled C/C++ driver version => 2.2.2 Persistent Clusters => 0 Persistent Sessions => 0
Directive => Local Value => Master Value cassandra.log => cassandra.log => cassandra.log cassandra.log_level => ERROR => ERROR
But still the error no class Cassandra.
UPDATE 2
Everything working now.
php > $cluster = Cassandra::cluster()->build();
php > var_dump($cluster);
object(Cassandra\DefaultCluster)#2 (0) { }
php >
Upvotes: 1
Reputation: 406
Since you are trying to execute your PHP script using nginx+fpm you will need to update the appropriate php.ini file (e.g. /etc/php7/fpm/php.ini
).
Add the driver module to your nginx+fpm installation
echo -e "; DataStax PHP Driver\nextension=cassandra.so" >> /etc/php/7.0/fpm/php.ini
To ensure the the driver is being properly loaded via CLI you can execute the following:
php -m | grep cassandra
or
php -i | grep -A 10 "^cassandra$"
php -m
will print out all the extension/modules that PHP was able to load whereas php -i
will display more verbose information about your PHP installation configuration.
Upvotes: 4