ubuntu下安装redis-server和phpredis
1,如果没有phpize,首先安装php5-dev
sudo apt-get install php5-dev
2,获取最新的redis代码,并且编译安装
wget http://redis.googlecode.com/files/redis-2.4.15.tar.gz
tar xzvf redis-2.4.15.tar.gz
cd redis-2.4.15
make
make install
3,安装phpredis,获取最新的版本代码进行编译
wget --no-check-certificate http://github.com/nicolasff/phpredis/tarball/master -O phpredis.tar.gz
tar phpredis.tar.gz
cd nicolasff-phpredis-f1231c9
phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
4,修改php.ini,添加redis.so模块
vim /etc/php5/apache2/php.ini
vim /etc/php5/cli/php.ini
都添加下面一行
extension=redis.so
5,重启apache
/etc/init.d/apache restart
6,下载redis的WEB管理包
wget --no-check-certificate https://github.com/ErikDubbelboer/phpRedisAdmin/tarball/master -O phpRedisAdmin.tar.gz
tar xzvf phpRedisAdmin.tar.gz
mkdir /var/www/redis
cp -fr ErikDubbelboer-phpRedisAdmin-9fcb29d/* /var/www/redis/
打开浏览器,输入如下地址:
7,php测试代码
<?php
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
$redis->set('key', 'hello world');
echo $redis->get('key');
?>