Centosphp安裝cassandra擴充套件

OldBoy~發表於2018-11-29

一、準備

當前php版本PHP Version 5.5.10,首先去http://pecl.php.net/package/cassandra,找到對應的php版本

二、下載安裝

# wget http://101.110.118.47/pecl.php.net/get/cassandra-1.2.1.tgz
# tar -zxvf cassandra-1.2.1.tgz
# cd cassandra-1.2.1
# /usr/local/php/bin/phpize
# ./configure

遇到的一系列報錯

報錯①:checking for supported DataStax C/C++ driver version... gawk: cmd. line:1: fatal: cannot open file `/include/cassandra.h' for reading (No such file or directory)

checking for supported DataStax C/C++ driver version... gawk: cmd. line:1: fatal: cannot open file `/include/cassandra.h' for reading (No such file or directory)

解決:需要安裝cpp的drive

當前所在目錄/usr/local/src下執行以下命令

# git clone https://github.com/datastax/cpp-driver.git
# mkdir cpp-driver/build
# cd cpp-driver/build
# cmake ..
# make

報錯②:configure: error: Unable to load libuv

configure: error: Unable to load libuv

解決:

# wget https://github.com/libuv/libuv/archive/ v1.4.2.tar.gz 
# tar -zxvf v1.4.2.tar.gz 
# cd /usr/local/src/libuv-1.4.2
# sh autogen.sh
# ./configure
# make 
# make install

報錯③:/usr/include/gnu/stubs.h:7:27: error: gnu/stubs-32.h:No such file or directory

/usr/include/gnu/stubs.h:7:27: error: gnu/stubs-32.h:No such file or directory

解決:

# yum -y install glibc-devel.i686

 報錯④: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.

 WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.

解決:

https://blog.csdn.net/a454213722/article/details/51866100

報錯⑤:/usr/local/src/cpp-driver/src/event_loop.cpp:63: error: ‘uv_print_all_handles’ was not declared in this scope

/usr/local/src/cpp-driver/src/event_loop.cpp:63: error: ‘uv_print_all_handles’ was not declared in this scope

解決:百度、360、必應、谷歌都走了,出現類似錯誤的很多(was not declared in this scope),但是沒有一個完全對應的解決方案,反正意思就是函式不存在。

簡單粗暴,編輯/usr/local/src/cpp-driver/src/event_loop.cpp:63檔案

# vim  /usr/local/src/cpp-driver/src/event_loop.cpp
//然後找到63行,把整行刪掉    // uv_print_all_handles(loop(), stderr);

把一系列問題解決之後,在當前目錄下/usr/local/src/cassandra-1.2.2

# make
# make install
Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/  //ok,然後在php.ini裡開啟cassandra擴充套件就可以了

 編輯php.ini檔案

#vim /usr/local/php/etc/php.ini

//增加
extension=cassandra.so

然後重啟php服務

意外!!!!意外!!!!TMD~~~

報錯⑥:

 NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/cassandra.so' - libcassandra.so.2: cannot open shared object file: No such file or directory in Unknown on line 0

 NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/cassandra.so' - libcassandra.so.2: cannot open shared object file: No such file or directory in Unknown on line 0

TMD明明目錄下有cassandra.so檔案,可TMD說沒有。。。

解決:

百度到一個帖子說:這個問題是缺少/usr/local/lib64/libcassandra.so.2檔案,經查詢發現/usr/lib64/libcassandra.so.2存在,建立軟體接至lib64中

ln -s /usr/local/lib64/libcassandra.so.2 /usr/lib64/libcassandra.so.2

 提示⑦:

在make install的時候還報過這玩意兒?????

/bin/sh /usr/local/src/cassandra-1.2.2/libtool --mode=install cp ./cassandra.la /usr/local/src/cassandra-1.2.2/modules
cp ./.libs/cassandra.so /usr/local/src/cassandra-1.2.2/modules/cassandra.so
cp ./.libs/cassandra.lai /usr/local/src/cassandra-1.2.2/modules/cassandra.la
PATH="$PATH:/sbin" ldconfig -n /usr/local/src/cassandra-1.2.2/modules
----------------------------------------------------------------------
Libraries have been installed in:
/usr/local/src/cassandra-1.2.2/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,--rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/

/bin/sh /usr/local/src/cassandra-1.2.2/libtool --mode=install cp ./cassandra.la /usr/local/src/cassandra-1.2.2/modules
cp ./.libs/cassandra.so /usr/local/src/cassandra-1.2.2/modules/cassandra.so
cp ./.libs/cassandra.lai /usr/local/src/cassandra-1.2.2/modules/cassandra.la
PATH="$PATH:/sbin" ldconfig -n /usr/local/src/cassandra-1.2.2/modules
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/local/src/cassandra-1.2.2/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/

在SF看到的答案:

這是告訴你接下來要怎麼用。簡單的辦法是在 /etc/ld.so.conf.d 下新建一個檔案 local.conf,裡邊寫上 /usr/local/lib。然後以 root 許可權執行 ldconfig。這樣你的系統才會找得到安裝到 /usr/local/lib 下的庫檔案

# echo "/usr/local/lib" >> /etc/ld.so.conf
# /usr/local/lib/ldconfig

 

 

 

相關文章