CentOS5.2にPHP5.2.6とmemcachedをインストールする
パソコン結構はまったがなんとか解決したので書いておきます。
まずはPHP5.2.6のインストールはyumで行います。
このあたりはweb上に結構情報がありますのでわかりにくければ探してみてください。
1.GPGキーインポート
2.yumリポジトリ追加
[utterramblings]
name=Jason’s Utter Ramblings Repo
baseurl=http://www.jasonlitka.com/media/EL$releasever/$basearch/
enabled=0
gpgcheck=1
gpgkey=http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka
3.yumでphpをインストール
(他に必要なモジュールは適当に。すでにphp5.1系がインストール
されている場合はupdateコマンドを利用です)
ここで、phpは完了。続いてmemcachedをインストールです。こいつは
rpmforgeのレポジトリを利用です。
4.yumでmemcachedをインストール
memcachedの設定は以下のあたり…
# cat /etc/php.d/memcache.ini
ここまではOKでした。続いてphpでmemcachedを扱えるようにするため
php-pecl-memcacheを入れます。
5.yumでphp-pecl-memcacheをインストール
6.httpdを再起動
7.phpでmemcachedがちゃんと使えるようになっているか確認
ここでこんなエラーが出て動いていないようです。
Module compiled with module API=20050922, debug=0, thread-safety=0
PHP compiled with module API=20060613, debug=0, thread-safety=0
These options need to match
in Unknown on line 0
/etc/php.d/memcache.ini,
あーなんかバージョンがあっていないようです。
いろいろ調べたところphp-pecl-memcacheをあげればよさそう。
8.php-pecl-memcacheを更新します
……….
running: phpize
sh: phpize: command not found
ERROR: `phpize’ failed
あ、エラーだ…
phpizeが入っていなかったらしい。
php5.2にあわせたものが必要なので
よし、再実行。
downloading memcache-2.2.4.tgz …
Starting to download memcache-2.2.4.tgz (35,389 bytes)
……done: 35,389 bytes
11 source files, building
running: phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
1. Enable memcache session handler support? : yes
1-1, ‘all’, ‘abort’, or Enter to continue:
ここで Enter
…….
checking for the location of ZLIB… no
checking for the location of zlib… configure: error: memcache support requires ZLIB. Use –with-zlib-dir=<DIR> to specify prefix where ZLIB include and library are located
ERROR: `/tmp/pear/download/memcache-2.2.4/configure –enable-memcache-session=yes’ failed
あ、またエラーだ…
今度はZLIBが入っていなかった。
これはphp5.2とは関係ないから
よし、再実行。
…….
Build process completed successfully
Installing ‘/usr/lib/php/modules/memcache.so’
upgrade ok: channel://pecl.php.net/memcache-2.2.4
configuration option “php_ini” is not set to php.ini location
You should add “extension=memcache.so” to php.ini
うん。どうやらうまくいったみたいだ。
確認してみましょう。
/etc/php.d/memcache.ini,
memcache
memcache support => enabled
memcache.allow_failover => 1 => 1
memcache.chunk_size => 8192 => 8192
memcache.default_port => 11211 => 11211
memcache.hash_function => crc32 => crc32
memcache.hash_strategy => standard => standard
memcache.max_failover_attempts => 20 => 20
Registered save handlers => files user memcache
やれやれ。これでインストール&セットアップは完了です。
