PHP Startup: Unable to load dynamic library 'cassandra.so' Ubuntu 18.04

时间:2018-08-22 13:43:28

标签: php cassandra ubuntu-18.04

I have install php-cassandra from apt-get in Ubuntu 18.04.

sudo apt-get install php-cassandra 

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  php-cassandra
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 3,892 B of archives.
After this operation, 21.5 kB of additional disk space will be used.
Get:1 http://in.archive.ubuntu.com/ubuntu bionic/universe amd64 php-cassandra amd64 1.3.0-1build1 [3,892 B]
Fetched 3,892 B in 0s (11.0 kB/s)        
Selecting previously unselected package php-cassandra.
(Reading database ... 256791 files and directories currently installed.)
Preparing to unpack .../php-cassandra_1.3.0-1build1_amd64.deb ...
Unpacking php-cassandra (1.3.0-1build1) ...
Setting up php-cassandra (1.3.0-1build1) ...

=================================================

php test_cass.php 

PHP Warning:  PHP Startup: Unable to load dynamic library 'cassandra.so' (tried: /usr/lib/php/20170718/cassandra.so (/usr/lib/php/20170718/cassandra.so: cannot open shared object file: No such file or directory), /usr/lib/php/20170718/cassandra.so.so (/usr/lib/php/20170718/cassandra.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Fatal error:  Uncaught Error: Class 'Cassandra' not found in /home/prabhakarc/php_programs/test_cass.php:3
Stack trace:
#0 {main}
  thrown in /home/prabhakarc/php_programs/test_cass.php on line 3

Thanks in advance.

EDIT:

Contents of test_cass.php:

<?php
  $cluster = new Cassandra::cluster()->withContactPoints('127.0.0.1')->build();
  $session = $cluster->connect("<Keyspace>");
  $statement = new Cassandra\SimpleStatement("SELECT * FROM <table>"); 
  $result = $session->execute($statement);
  echo "Result contains " . $result->count() . " rows"; ?> –

1 个答案:

答案 0 :(得分:1)

尝试一下: 转到您的php.ini文件,查找cassandra.so并将其注释掉。您的.ini文件应位于/etc/php/your-php-version/cli/php.ini/etc/php/your-php-version/apache/php.ini中。像这样;extension=cassandra.so,在其前面加上分号来注释掉该行。然后通过sudo service apache2 restart重启apache。