如何修复Cassandra PHP驱动安装时的ini文件缺失及编译错误
Fixing Cassandra PHP Driver Installation Issues
Let's walk through solutions for both of the problems you're facing when setting up the Cassandra PHP driver.
1. Resolving "WARNING: Module cassandra ini file doesn't exist under /etc/php/7.1/mods-available"
This warning pops up because the PHP module configuration file for Cassandra isn't present in the expected directory. Here's how to fix it:
- First, create the missing
cassandra.inifile in the mods-available directory:echo "extension=cassandra.so" | sudo tee /etc/php/7.1/mods-available/cassandra.ini - Enable the module for PHP 7.1 specifically:
sudo phpenmod -v 7.1 cassandra - Restart your web server or PHP-FPM to apply the changes (use the command matching your setup):
# For Apache sudo systemctl restart apache2 # For PHP-FPM sudo systemctl restart php7.1-fpm - Verify the module is loaded by running:
If you seephp -m | grep cassandracassandrain the output, the warning should be resolved.
2. Fixing "cannot open /include/cassandra.h" and "Driver version 2.7.0+ required" Errors
These errors stem from a missing or outdated Cassandra C/C++ Driver (libcassandra), which the PHP driver depends on. Follow these steps to fix it:
- First, clean up any partial installations of the PHP driver:
sudo apt-get purge --auto-remove cassandra-php-driver - Add the DataStax repository to access the correct version of the C driver:
echo "deb https://debian.datastax.com/community stable main" | sudo tee /etc/apt/sources.list.d/datastax.list curl -L https://debian.datastax.com/debian/repo_key | sudo apt-key add - sudo apt-get update - Install the required C driver packages (ensure version ≥2.7.0):
sudo apt-get install libcassandra-dev libcassandra2 - Confirm the installed version meets the requirement:
dpkg -l libcassandra2 | grep Version - Now reinstall the Cassandra PHP driver deb package you downloaded (replace the path with your actual file location):
sudo dpkg -i /path/to/cassandra_php_driver-v1.3.2-ubuntu16.04_amd64.deb - If you still run into issues, try installing via PECL instead (often more reliable for module setup):
After this, repeat the steps from the first problem to create and enable the ini file.# Install build dependencies first sudo apt-get install php7.1-dev gcc make # Install the driver via PECL sudo pecl install cassandra
内容的提问来源于stack exchange,提问作者Abhishek
相关产品推荐
相关产品推荐

