简体   繁体   中英

PHP Warning: PHP Startup: Unable to load dynamic library 'cassandra.so' (tried: /usr/lib/php/20170718/cassandra

I'm setting up square api, integrated it in client side and now working on server side but for that i need to manage dependencies with composer , while installing composer I got above error.

I was installing composer, when i run composer install , composer was installed but I got the PHP warning in addition ie

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

I googled and tried all the solutions that have already been done, but none worked to mine. I have tried:

  1. To find out cassandra at php.ini in /etc/php/7.2/cli but i did't find it.
  2. To install Cassandra by using command sudo apt-get install php-cassandra in /usr/lib/php/20170718 , but it still shows the same error.
  3. Update and upgrade the Ubuntu, to make sure that there are no internal errors, if there was any?

I expect to install cassandra and load it dynamically.

The DataStax PHP driver extension is a wrapper around the C/C++ driver and requires installation of all of its dependencies:

Since you are using the PHP driver with PHP v7.2 you will need to build the extension as their are no pre-built binaries for this version of PHP:

git clone https://github.com/datastax/php-driver.git
cd php-driver/ext
phpize
cd ..
mkdir build
cd build
../ext/configure
make
sudo make install

Note : The development packages of all of dependencies will be required in order to properly build the extension.

Once the driver is installed you will need to edit your php.ini file to enable the extension which can be located by executing php -r "echo php_ini_loaded_file();":

; DataStax PHP Driver for Apache Cassandra
extension=cassandra.so

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM