为Cassandra安装PHP驱动程序

时间:2016-02-08 14:46:14

标签: php apache ubuntu cassandra driver

我在linode上创建服务器并安装了Ubuntu 15.10并在我的控制台中输入install for php命令

apt-get update
apt-get install -y php5
sudo apt-get install php5-dev

然后,我安装了软件:boost,openssl,libtool和cmake

sudo apt-get install libboost-all-dev
sudo apt-get install openssl
apt-get install cmake

sudo apt-get install automake libtool curl
curl -sSL https://github.com/libuv/libuv/archive/v1.4.2.tar.gz | sudo tar zxfv - -C /usr/local/src
cd /usr/local/src/libuv-1.4.2
sudo sh autogen.sh
sudo ./configure
sudo make 
sudo make install
sudo rm -rf /usr/local/src/libuv-1.4.2 && cd ~/
sudo ldconfig
sudo apt-get install libssl-dev

然后,我安装了cassnadra使用datastax文档

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 -
sudo apt-get update
sudo apt-get install dsc20=2.0.11-1 cassandra=2.0.11

我检查过cassnadra

sudo service cassandra status

我明白了:

● cassandra.service - LSB: distributed storage system for structured data
   Loaded: loaded (/etc/init.d/cassandra)
   Active: active (running) since Mon 2016-02-08 09:12:59 EST; 21s ago
     Docs: man:systemd-sysv-generator(8)
   CGroup: /system.slice/cassandra.service
           └─27880 java -ea -javaagent:/usr/share/cassandra/lib/jamm-0.2.5.jar -XX:+CMSClassUnloadingEnabled -XX:+UseThreadPriorities -XX:Threa...

Feb 08 09:12:59 ubuntu systemd[1]: Starting LSB: distributed storage system for structured data...
Feb 08 09:12:59 ubuntu systemd[1]: Started LSB: distributed storage system for structured data.

我检查集群的状态和cqlsh:

sudo 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  41.32 KB   256     100.0%            2eaa4bd9-136d-4c2a-a65e-7444eb9d8824  rack1

Connected to Test Cluster at localhost:9160.
[cqlsh 4.1.1 | Cassandra 2.0.11 | CQL spec 3.1.1 | Thrift protocol 19.39.0]
Use HELP for help.

一切正常!最后我尝试为Cassandra安装PHP Driver使用它:

git clone https://github.com/datastax/cpp-driver.git
cd cpp-driver
cmake . && make && make install
ln -s libcql.so.0.7.0 /usr/lib/libcql.so.0
ln -s /usr/lib/libcql.so.0 /usr/lib/libcql.so
git clone https://github.com/aparkhomenko/php-cassandra.git
cd php-cassandra
phpize && ./configure && make

但我得错误

checking for specified location of CQL library... yes, shared
checking for CQL in default path... not found
configure: error: Please reinstall the cassandra distribution

我的错误在哪里?

1 个答案:

答案 0 :(得分:1)

我认为问题在于您正在为C / C ++安装Cassandra的驱动程序:

  

git clone https://github.com/datastax/ cpp-driver .git

相反,你必须使用PHP:

git clone https://github.com/datastax/php-driver.git
cd php-driver
git submodule update --init
cd ext
./install.sh

然后,在php.ini中添加扩展名。 对于apache2:

echo -e "; DataStax PHP Driver\nextension=cassandra.so" >> /etc/php5/cli/php.ini
echo -e "; DataStax PHP Driver\nextension=cassandra.so" >> /etc/php5/apache2/php.ini

/etc/init.d/apache2 reload

你之前所做的一切都很好。

来源:https://github.com/datastax/php-driver/blob/master/ext/README.md