Redisインストール

Redis 2.6.12インストール

最新版のソースからインストール

wget https://redis.googlecode.com/files/redis-2.6.12.tar.gz
tar zxfv redis-2.6.12.tar.gz
cd redis-2.6.12
make
make test

make testでtcl 8.5が必要とエラー

cd src && make test
make[1]: Entering directory `/usr/local/src/redis-2.6.12/src'
You need tcl 8.5 or newer in order to run the Redis test
make[1]: *** [test] Error 1
make[1]: Leaving directory `/usr/local/src/redis-2.6.12/src'
make: *** [test] Error 2

tcl 8.5インストールをインストール

wget http://prdownloads.sourceforge.net/tcl/tcl8.5.13-src.tar.gz
tar xzvf tcl8.5.13-src.tar.gz 
cd tcl5.8.13/unix
./configure
make
make test
make install

再度make testしてみる。
問題なかったのでmake install!!

make test
make install

which redis-server

これでインストール完了。
次は起動スクリプトの設定。install_server.shが用意されているので実行。

cd util
./install_server.sh

問題なく実行されたが、init.dの起動スクリプトの改行がおかしかったので修正。

vim /etc/init.d/redis_6379
%s/\\n/\r/g

起動してみる

/etc/init.d/redis_6379 start

最後にredis-cliコマンドで簡単な接続確認

redis-cli

redis 127.0.0.1:6379> set hoge foo
OK
redis 127.0.0.1:6379> get hoge
foo


これでインストールと起動まで完了。
次はPHPから利用する為に、phpredisを入れてみよう。