安裝redis和phpredis模塊

安裝redis

shell> wget http://redis.googlecode.com/files/redis-2.0.4.tar.gz
shell> tar zxvf redis-2.0.4.tar.gz
shell> mv redis-2.0.4 redis
shell> cd redis
shell> make
shell> redis-server 不要關
shell> redis-cli
redis>set foo bar
OK
redis>get foo
"bar"
 
安裝phpredis模塊
https://github.com/owlient/phpredis
下載phpredis
解壓
shell> cd phpredis
shell> /usr/local/php/bin/phpize      這個phpize是安裝php模塊的
shell> ./configure --with-php-config=/usr/local/php/bin/php-config
shell> make
shell> make install
接下來在php.ini中添加extension=redis.so   先要看看有沒有extension_dir=/.......
重啓apache或者nginx
 
php代碼測試
<?php
$redis = new Redis();
$redis->connect('127.0.0.1',6379);
$redis->set('test','hello world!');
echo $redis->get('test');
?>
 
輸出hello world!
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章