红联Linux门户
Linux帮助

ubuntu安装redisphp扩展

发布时间:2015-09-30 10:46:54来源:linux网站作者:hulk_wan

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/

打开浏览器,输入如下地址:

http://192.168.123.136/redis/


7,php测试代码
<?php 
$redis = new Redis(); 
$redis->connect('127.0.0.1', 6379); 
$redis->set('key', 'hello world'); 
echo $redis->get('key'); 
?>


Linux(CentOS 5.5)Redis安装及RedisPHP拓展安装应用:http://www.linuxdiyf.com/linux/6195.html