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

  作者:zhanhailiang 日期:2014-10-16

推荐阅读:

  1. Redis持久化策略
  2. 关于Redis更多资料阅读

1. 下载redis-2.8.17.tar.gz:http://download.redis.io/releases/redis-2.8.17.tar.gz

2. 编译安装配置如下:

[redis-2.8.17]# make
[redis-2.8.17]# make PREFIX=/usr/local/redis-2.8.17 install
[redis-2.8.17]# ln -s /usr/local/redis-2.8.17/bin/redis-benchmark /usr/bin/redis-benchmark
[redis-2.8.17]# ln -s /usr/local/redis-2.8.17/bin/redis-check-aof /usr/bin/redis-check-aof
[redis-2.8.17]# ln -s /usr/local/redis-2.8.17/bin/redis-check-dump /usr/bin/redis-check-dump
[redis-2.8.17]# ln -s /usr/local/redis-2.8.17/bin/redis-cli /usr/bin/redis-cli
[redis-2.8.17]# ln -s /usr/local/redis-2.8.17/bin/redis-server /usr/bin/redis-server
 
[redis-2.8.17]# cd utils
[utils]# ./install_server.sh
Welcome to the redis service installer
This script will help you easily set up a running redis server
 
Please select the redis port for this instance: [6379]
Selecting default: 6379
Please select the redis config file name [/etc/redis/6379.conf] /usr/local/redis-2.8.17/conf/redis_6379.conf
Please select the redis log file name [/var/log/redis_6379.log] /usr/local/redis-2.8.17/log/redis_6379.log
Please select the data directory for this instance [/var/lib/redis/6379] /usr/local/redis-2.8.17/data/6379
Please select the redis executable path [/usr/bin/redis-server]
Selected config:
Port           : 6379
Config file    : /usr/local/redis-2.8.17/conf/redis_6379.conf
Log file       : /usr/local/redis-2.8.17/log/redis_6379.log
Data dir       : /usr/local/redis-2.8.17/data/6379
Executable     : /usr/bin/redis-server
Cli Executable : /usr/bin/redis-cli
Is this ok? Then press ENTER to go on or Ctrl-C to abort.

接着开启AOF模式:appendonly yes

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

通过redis服务命令重启下redis:

[redis-2.8.17]# /etc/init.d/redis_6379 --help
Please use start, stop, restart or status as first argument
[redis-2.8.17]# /etc/init.d/redis_6379 restart
Please use start, stop, restart or status as first argument

3. 下载igbinary扩展包(redis扩展包–enable-redis-igbinary依赖igbinary扩展包):http://pecl.php.net/get/igbinary-1.2.1.tgz

[redis-2.8.17]# /usr/local/php/bin/phpize
[redis-2.8.17]# ./configure --with-php-config=/usr/local/php/bin/php-config  --enable-igbinary
[redis-2.8.17]# make && make install

4. 下载redis扩展包:http://download.redis.io/releases/redis-2.8.17.tar.gz

[redis-2.8.17]# /usr/local/php/bin/phpize
[redis-2.8.17]# ./configure --with-php-config=/usr/local/php/bin/php-config  --enable-redis  --enable-redis-igbinary
[redis-2.8.17]# make && make install

5. 修改php.ini配置:

; /usr/local/php/etc/php.ini
extension=igbinary.so
extension=redis.so

6. 测试扩展是否正常加载:

[redis-2.8.17]# /usr/local/php/bin/php -m
[PHP Modules]
...
igbinary
...
redis
...
 
[Zend Modules]

7. 测试代码如下:

<?php
$redis = new Redis();
$redis->connect(‘127.0.0.1‘, 6379);
$count = $redis->dbSize();
echo "Redis has $count keys\n";
 
$ret = $redis->get(‘test5‘);
var_dump($ret);

8. 安装配置Redis WEB管理工具phpRedisAdmin:https://github.com/ErikDubbelboer/phpRedisAdmin

[phpredisadmin]# git clone https://github.com/ErikDubbelboer/phpRedisAdmin.git
[phpredisadmin]# cd phpRedisAdmin
[phpredisadmin]# git clone https://github.com/nrk/predis.git vendor

然后配置相应nginx配置即可看到当前Redis服务状态:

至此redis环境配置就完成了。

时间: 2025-01-20 16:16:51

redis安装配置教程及phpredis扩展安装测试的相关文章

搭建coreseek(sphinx+mmseg3)详细安装配置+php之sphinx扩展安装+php调用示例

http://blog.csdn.net/e421083458/article/details/21529969 常用的命令 ps -ef|grep searchd 如果你开了search服务后,你命令比如 indexer search 后面都需要带上 --rotate ./indexer --all ./searchd 至于其它什么命令 看手册 collect2: ld returned 1 exit status make[2]: *** [indexer] Error 1 make[2]:

redis安装+redis集群配置+phpredis扩展安装

安装前的准备: redis-3.0tar.gz    官网下载地址    http://redis.io/download/以下软件或直接yum安装也可(安装步骤略)tcl8.6.1-src.tar.gz               官网下载地址   http://sourceforge.jp/projects/sfnet_tcl/releases/rubygems-2.4.2.zip            官网下载地址   http://rubygems.org/pages/download/

linux下Redis与phpredis扩展安装

++++++++++++++++++++++++++++++++++++++++++++++linux下Redis与phpredis扩展安装++++++++++++++++++++++++++++++++++++++++++++++操作系统   : [CentOS6.0]redis  : [redis-2.4.3]phpredis   : [phpredis-2.1.0]++++++++++++++++++++++++++++++++++++++++++++++准备安装软件(download) 

***phpredis扩展安装总结

phpredis扩展安装总结:PHP扩展安装在[[email protected] lampp]# cd include 目录下创建一个目录phpredis下载扩展:wget https://github.com/nicolasff/phpredis/archive/master.tar.gz解压:[[email protected] phpredis]# tar xvf master.tar.gz运行:[[email protected] phpredis-master]# /opt/lamp

PHP调试工具Xdebug安装配置教程

PHP调试工具Xdebug安装配置教程 说到PHP代码调试,对于有经验的PHPer,通过echo.print_r.var_dump函数,或PHP开发工具zend studio.editplus可解决大部分问题,但是对于PHP入门学习的童鞋来说有一定的难度,而且仅仅通过上述这些PHP调试手段,也很难准确发现PHP性能方面的问题,Xdebug是一个非常有用的PHP调试工具. Xdebug作为PHP调试工具,提供了丰富的调试函数,也可将Xdebug安装配置为zend studio.editplus调试

Windows上PostgreSQL安装配置教程

Windows上PostgreSQL安装配置教程 这篇文章主要为大家详细介绍了Windows上PostgreSQL安装配置教程,具有一定的参考价值,感兴趣的小伙伴们可以参考一下 PostgreSQL的扩展PostGIS是最著名的开源GIS数据库. 安装PostgreSQL是第一步. 1.下载PostgreSQL的二进制安装文件. PostgreSQL官网–>Download–>Windows 64位,如图所示: (1)官网: https://www.postgresql.org/ (2)Dow

GNS3-1.4 加 vm-iou 安装配置教程

GNS3-1.4 加 vm-iou 安装配置教程      下载地址 http://down.51cto.com/data/2151906 作者:赵明.李震 1.教程意义 对于网络工程师来说,敲实验室是日常娱乐的一种方式.工欲善其事必先利其器,gns3 和 iou.vm 我就不介绍了,之前的 gns3 版本对于交换机的实验模拟存在不足,比如 mst 就无 法配置:虽然 iou 可以解决该问题,但是 iou 本身可视化较差,安装配置复杂,拓扑搭建麻 烦.故今天给大家分享下,使用最新版的 gns3-

OPENVPN安装配置教程总结 centosX64

1.安装openvpn依赖组件 2.安装openvpn 3.初始化CA证书 4.生成CA证书,生成server证书,生成client证书 5.编辑/etc/sysctl.conf,添加路由规则. 6.生成Diffie Hellman参数 7.将server 证书 dh1024.pem ca证书copy到 /etc/openvpn 8.将server.conf 复制到 /etc/openvpn目录下并依据自己要求编辑此配置文件 9.配置启动脚本启动server 端 10.配置客户端,连接客户端 详

jmeter安装配置教程

jmeter安装配置教程 1.下载Jmeter 下载地址:http://jmeter.apache.org/download_jmeter.cgi 目前最新版为3.1,其余文件如源代码等也可从如下官网下载: http://jmeter.apache.org/download_jmeter.cgi 2.安装Jmeter之前 安装Jmeter之前需要先配置Java环境,我们下载的是jmeter3.1,所以java版本最好是选用java6以后的版本. 安装JDk1.6的步骤如下: 点击下载的JDK文件