1

みなさん、良い一日を。

通常、* nix OSでこの公式ドキュメントを使用しています

しかし、今は MacO を使用していますが、この手順は正しく機能しません。

pecl install cassandraこのメッセージを受け取った場合:

checking for supported DataStax C/C++ driver version... awk: can't open file /include/cassandra.h
 source line number 1
configure: error: not supported. Driver version 2.4.2+ required (found )
ERROR: `/private/tmp/pear/install/cassandra/configure --with-php-config=/usr/bin/php-config' failed

私の論理では、その場合、DataStax C/C++ ドライバーを自分で作成する必要があることがわかります。フォルダー内で、この命令php-driver\libを削除cpp-driverして使用すると、エラーなしで新しくて新鮮な C/C++ ドライバーが作成されます。

したがって、公式ドキュメントでは次のように述べています。

注 install.sh スクリプトは、Apache Cassandra 用の DataStax C/C++ ドライバーのサブモジュール化されたバージョンもコンパイルし、拡張機能に静的にリンクします。システムに既にあるバージョンの cpp ドライバーを使用するには、phpize を実行し、./configure を実行して、make install します。

./configureしかし、から実行しようとするとphp-drive/ext、ほぼ同じエラーが発生しました:

checking for supported DataStax C/C++ driver version... awk: can't open file /include/cassandra.h
 source line number 1
configure: error: not supported. Driver version 2.4.2+ required (found )

続行しても、そのエラーが実行make installされた後、次のログが表示されます。

/bin/sh /Users/antvirgeo/php-driver/ext/libtool --mode=install cp ./cassandra.la /Users/antvirgeo/php-driver/ext/modules
cp ./.libs/cassandra.so /Users/antvirgeo/php-driver/ext/modules/cassandra.so
cp ./.libs/cassandra.lai /Users/antvirgeo/php-driver/ext/modules/cassandra.la
----------------------------------------------------------------------
Libraries have been installed in:
   /Users/antvirgeo/php-driver/ext/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 `DYLD_LIBRARY_PATH' environment variable
     during execution

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/lib/php/extensions/no-debug-non-zts-20121212/
cp: /usr/lib/php/extensions/no-debug-non-zts-20121212/#INST@24727#: Operation not permitted
make: *** [install-modules] Error 1

ライブラリは次の場所にインストールされています:
/Users/antvirgeo/php-driver/ext/modules

そのパスで cassandra 拡張機能を php.ini に追加してもClass 'Cassandra\SimpleStatement' not found、プロジェクトでエラーが発生します。

php -d="extension=modules/cassandra.so" -mcassandraPHPモジュールのリストでそれを示しています

私は何を間違っていますか?

PS: このプロジェクトでは、Parallels に ubuntu OS があり、この手順でインストールされた DataStax php ドライバーは正常に動作します。

____upd: エラーのない @Fero のすべての指示の後コマンドで次のように/usr/local/bin/php -i | grep -A 10 "^cassandra$"表示されます。

cassandra

Cassandra support => enabled
C/C++ driver version => 2.4.2
Persistent Clusters => 0
Persistent Sessions => 0

Directive => Local Value => Master Value
cassandra.log => cassandra.log => cassandra.log
cassandra.log_level => ERROR => ERROR

それでも同じエラー -Class 'Cassandra\SimpleStatement' not found

______________最終更新:

ああ、それは働いています!私は自分のプロジェクトで出力を書きphpinfo();、Apache が他の php バージョンを使用していることに気付きphp.iniましextension=cassandra.soた。

4

2 に答える 2

0

Cassandra PHP 拡張機能を MacOS にインストールする必要がある場合は、システム整合性保護のオン/オフを切り替えることなく、PECL 経由でインストールするだけで簡単にインストールできます。簡単なステップバイステップの手順を記載したブログ記事を書きました。今年の 4 月に Homebrew/php タップが削除されたため、Homebrew から PHP をインストールするためのリンクも含まれています。

また、DataStax Web サイトに記載されている誤った指示も回避します。要するに ...

依存関係をインストールします (メッセージを簡単に表示するために、これらのコマンドを一度に 1 つずつ実行します)。

$ brew install autoconf
$ brew install cmake
$ brew install automake
$ brew install libtool
$ brew install gmp
$ brew install libuv
$ brew install openssl

C++ ドライバーを取得してビルドし、cpp-driver フォルダー内にビルド ディレクトリを作成します。

$ git clone https://github.com/datastax/cpp-driver.git --depth=1
$ mkdir cpp-driver/build
$ cd cpp-driver/build

OpenSSL への修飾された呼び出しを使用して、ドライバーを作成およびビルドします。

$ cmake -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl/ -DOPENSSL_LIBRARIES=/usr/local/opt/openssl/lib ..
$ make
$ make install

これで、PECL を使用して Cassandra PHP 拡張ライブラリをインストールできます。

$ pecl install cassandra

Cassandra 拡張機能が PHP.ini ファイルに追加されていることを確認してください。そうでない場合は追加します。

[cassandra]
extension="cassandra.so"

Apache を再起動すると、PHP で Cassandra を実行できます。

上記の手順で何が起こっているかについて詳しく知りたい場合は、次のブログ投稿を参照してください。

https://medium.com/@crmcmullen/how-to-install-the-cassandra-php-driver-on-macos-10-13-high-sierra-and-10-14-mojave-c18263831ccb

于 2018-09-30T22:25:54.750 に答える