您当前的位置:首页 > redis

Redis安装配置教程及phpredis扩展安装测试

1. 下载redis-2.8.17.tar.gz:http://download.redis.io/releases/redis-2.8.17.tar.gz;P8wlinux系统宝典

2. 编译安装配置如下:P8wlinux系统宝典

[redis-2.8.17]# makeP8wlinux系统宝典
[redis-2.8.17]# make PREFIX=/usr/local/redis-2.8.17 installP8wlinux系统宝典
[redis-2.8.17]# ln -s /usr/local/redis-2.8.17/bin/redis-benchmark /usr/bin/redis-benchmarkP8wlinux系统宝典
[redis-2.8.17]# ln -s /usr/local/redis-2.8.17/bin/redis-check-aof /usr/bin/redis-check-aofP8wlinux系统宝典
[redis-2.8.17]# ln -s /usr/local/redis-2.8.17/bin/redis-check-dump /usr/bin/redis-check-dumpP8wlinux系统宝典
[redis-2.8.17]# ln -s /usr/local/redis-2.8.17/bin/redis-cli /usr/bin/redis-cliP8wlinux系统宝典
[redis-2.8.17]# ln -s /usr/local/redis-2.8.17/bin/redis-server /usr/bin/redis-serverP8wlinux系统宝典
 P8wlinux系统宝典
[redis-2.8.17]# cd utilsP8wlinux系统宝典
[utils]# ./install_server.sh P8wlinux系统宝典
Welcome to the redis service installerP8wlinux系统宝典
This script will help you easily set up a running redis serverP8wlinux系统宝典
 P8wlinux系统宝典
Please select the redis port for this instance: [6379] P8wlinux系统宝典
Selecting default: 6379P8wlinux系统宝典
Please select the redis config file name [/etc/redis/6379.conf] /usr/local/redis-2.8.17/conf/redis_6379.confP8wlinux系统宝典
Please select the redis log file name [/var/log/redis_6379.log] /usr/local/redis-2.8.17/log/redis_6379.logP8wlinux系统宝典
Please select the data directory for this instance [/var/lib/redis/6379] /usr/local/redis-2.8.17/data/6379P8wlinux系统宝典
Please select the redis executable path [/usr/bin/redis-server] P8wlinux系统宝典
Selected config:P8wlinux系统宝典
Port          : 6379P8wlinux系统宝典
Config file    : /usr/local/redis-2.8.17/conf/redis_6379.confP8wlinux系统宝典
Log file      : /usr/local/redis-2.8.17/log/redis_6379.logP8wlinux系统宝典
Data dir      : /usr/local/redis-2.8.17/data/6379P8wlinux系统宝典
Executable    : /usr/bin/redis-serverP8wlinux系统宝典
Cli Executable : /usr/bin/redis-cliP8wlinux系统宝典
Is this ok? Then press ENTER to go on or Ctrl-C to abort.接着开启AOF模式:appendonly yes:P8wlinux系统宝典

############################## APPEND ONLY MODE ###############################P8wlinux系统宝典
 P8wlinux系统宝典
# By default Redis asynchronously dumps the dataset on disk. This mode isP8wlinux系统宝典
# good enough in many applications, but an issue with the Redis process orP8wlinux系统宝典
# a power outage may result into a few minutes of writes lost (depending onP8wlinux系统宝典
# the configured save points).P8wlinux系统宝典
#P8wlinux系统宝典
# The Append Only File is an alternative persistence mode that providesP8wlinux系统宝典
# much better durability. For instance using the default data fsync policyP8wlinux系统宝典
# (see later in the config file) Redis can lose just one second of writes in aP8wlinux系统宝典
# dramatic event like a server power outage, or a single write if somethingP8wlinux系统宝典
# wrong with the Redis process itself happens, but the operating system isP8wlinux系统宝典
# still running correctly.P8wlinux系统宝典
#P8wlinux系统宝典
# AOF and RDB persistence can be enabled at the same time without problems.P8wlinux系统宝典
# If the AOF is enabled on startup Redis will load the AOF, that is the fileP8wlinux系统宝典
# with the better durability guarantees.P8wlinux系统宝典
#P8wlinux系统宝典
# Please check http://redis.io/topics/persistence for more information.P8wlinux系统宝典
 P8wlinux系统宝典
appendonly yes P8wlinux系统宝典
 P8wlinux系统宝典
# The name of the append only file (default: "appendonly.aof")P8wlinux系统宝典
 P8wlinux系统宝典
appendfilename "appendonly_6379.aof"通过redis服务命令重启下redis:P8wlinux系统宝典

[redis-2.8.17]# /etc/init.d/redis_6379 --helpP8wlinux系统宝典
Please use start, stop, restart or status as first argumentP8wlinux系统宝典
[redis-2.8.17]# /etc/init.d/redis_6379 restartP8wlinux系统宝典
Please use start, stop, restart or status as first argument3. 下载igbinary扩展包(redis扩展包–enable-redis-igbinary依赖igbinary扩展包):http://pecl.php.net/get/igbinary-1.2.1.tgzP8wlinux系统宝典

[redis-2.8.17]# /usr/local/php/bin/phpizeP8wlinux系统宝典
[redis-2.8.17]# ./configure --with-php-config=/usr/local/php/bin/php-config  --enable-igbinaryP8wlinux系统宝典
[redis-2.8.17]# make && make install4. 下载redis扩展包:http://download.redis.io/releases/redis-2.8.17.tar.gzP8wlinux系统宝典

[redis-2.8.17]# /usr/local/php/bin/phpizeP8wlinux系统宝典
[redis-2.8.17]# ./configure --with-php-config=/usr/local/php/bin/php-config  --enable-redis  --enable-redis-igbinaryP8wlinux系统宝典
[redis-2.8.17]# make && make install5. 修改php.ini配置:P8wlinux系统宝典

; /usr/local/php/etc/php.iniP8wlinux系统宝典
extension=igbinary.soP8wlinux系统宝典
extension=redis.so6. 测试扩展是否正常加载:P8wlinux系统宝典

[redis-2.8.17]# /usr/local/php/bin/php -mP8wlinux系统宝典
[PHP Modules]P8wlinux系统宝典
...P8wlinux系统宝典
igbinaryP8wlinux系统宝典
...P8wlinux系统宝典
redisP8wlinux系统宝典
...P8wlinux系统宝典
 P8wlinux系统宝典
[Zend Modules]7. 测试代码如下:P8wlinux系统宝典

<?phpP8wlinux系统宝典
$redis = new Redis();P8wlinux系统宝典
$redis->connect('127.0.0.1', 6379);P8wlinux系统宝典
$count = $redis->dbSize();P8wlinux系统宝典
echo "Redis has $count keys/n";P8wlinux系统宝典
 P8wlinux系统宝典
$ret = $redis->get('test5');P8wlinux系统宝典
var_dump($ret);8. 安装配置Redis WEB管理工具phpRedisAdmin:https://github.com/ErikDubbelboer/phpRedisAdminP8wlinux系统宝典

[phpredisadmin]# git clone https://github.com/ErikDubbelboer/phpRedisAdmin.gitP8wlinux系统宝典
[phpredisadmin]# cd phpRedisAdminP8wlinux系统宝典
[phpredisadmin]# git clone https://github.com/nrk/predis.git vendor然后配置相应nginx配置即可看到当前Redis服务状态:P8wlinux系统宝典

Redis安装配置教程及phpredis扩展安装测试 P8wlinux系统宝典

至此redis环境配置就完成了。P8wlinux系统宝典

14.04下Redis安装及简单测试 P8wlinux系统宝典

Redis集群明细文档 P8wlinux系统宝典

Ubuntu 12.10下安装Redis(图文详解)+ Jedis连接Redis P8wlinux系统宝典

Redis系列-安装部署维护篇 P8wlinux系统宝典

6.3安装Redis P8wlinux系统宝典

Redis安装部署学习笔记 P8wlinux系统宝典

Redis配置文件redis.conf 详解 P8wlinux系统宝典

Redis 的详细介绍P8wlinux系统宝典
Redis 的下载地址P8wlinux系统宝典



沪ICP备10206494号-4