LoginSignup
21
18

More than 5 years have passed since last update.

【PHP】PHP7でmemcachedを動かす

Posted at

まずはじめに

PHP7はどうやって入れたの?

前提として、PHP7はこちらを参照して入れました。
http://qiita.com/qiita-kurara/items/7f4619c04e5fee212147

参考にしたページ

「php7 memcached」でググると先人の方々が既にPHP7でmemcachedを動かすやり方についてまとめてくださっています。
http://blog.webmemo.red/linux/php7-memcached-extension-install/
http://dqn.sakusakutto.jp/2015/07/php7_trap.html

そのため、以上のページをご覧になってエラーが出ずに順調に設定ができ、phpinfo()で以下表示が出さえすればこの先は読まなくて大丈夫です。

スクリーンショット 2016-06-09 12.05.22.png

こちらでは、「この先ぶつかるかもしれない問題リスト」を以下にまとめておきました。

この先ぶつかるかもしれない問題リスト

php-memcachedの"./configure"で引っかかる

エラー1

checking for zlib location... configure: error: memcached support requires ZLIB. Use --with-zlib-dir=<DIR> to specify the prefix where ZLIB headers and library are located

ZLIBないっすよ。と怒られています。
このエラーが出た時は以下コマンドで解決

yum install zlib-devel

エラー2

configure: error: no, libmemcached sasl support is not enabled. Run configure with --disable-memcached-sasl to disable this check

Run configure with --disable-memcached-sasl

言われたとおりにコマンドを実行してみましょう。

./configure --disable-memcached-sasl

php-memcachedのmakeで引っかかる

"make" でエラーが発生

/usr/local/src/php-memcached/php_libmemcached_compat.h:56: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'php_memcached_instance_st'

この場合、yumで入れたlibmemcachedのバージョンが低くて引っかかっているようです。
(参考 : http://qiita.com/wata727/items/927ae072ccefe9e3de8c)
入れなおしましょう。

[root@test-web php-memcached]# yum remove libmemcached
[root@test-web php-memcached]# cd /url/local/src
[root@test-web src]# wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz

ちなみにここでwgetないよって言われたらwget入れてあげてください。

[root@test-web src]# yum install wget

気を取り直して以下コマンドでlibmemcachedを入れなおします。

[root@test-web src]# tar -zxvf libmemcached-1.0.18.tar.gz
[root@test-web src]# cd libmemcached-1.0.18
[root@test-web src]# ./configure --without-memcached && make && make install

memcached.soが読み込めなくて引っかかる

/usr/lib64/php/modules/にmemcached.soが読み込めない時はこんなエラーが出てきます。

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/memcached.so' - /usr/lib64/php/modules/memcached.so: cannot open shared object file: No such file or directory in Unknown on line 0

この時はphp.iniの設定が足りない可能性があります。
詳しくはこちらを参照 http://qiita.com/nnmr/items/778c3e9c4dbb7fb25a73

21
18
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
21
18