Linux下编译redis和phpredis的方法

本文讲述了Linux下编译redisPHPredis方法分享给大家供大家参考,具体如下:

1、准备工作

下载软件:。 操作系统:CentOS 5.5 redis 版本:redis-2.6.9

2、编译安装

如果出现如下错误:

解决方法:

当看见“Hint: To run 'make test' is a good idea ;)” 说明编译成功。

说明:其实 make install 就是:

这样,redis 就安装成功了。

接下来就是启动Redis了,上面编译后生成的那些可执行文件拷贝到了/usr/local/bin目录下面,他们的作用分别是:

redis-server:Redis服务器的daemon启动程序 redis-cli:Redis命令行操作工具。当然,你也可以用 telnet 根据其纯文本协议来操作 redis-benchmark:Redis性能测试工具,测试Redis在你的系统及你的配置下的读写性能

启动 Redis 进程只需要执行这个 /usr/local/bin/redis-server /path-to/redis.conf

启动的时候后面要跟上 redis 的配置文件, 这样Redis就顺利启动了.

3、启动 redis 会出现的问题

Warning: 32 bit instance detected but no memory limit set. Setting 3 GB maxmemory limit with 'noeviction' policy now.

解决方法:修改配置文件 redis.conf 将 maxmemory 设置为 maxmemory 1024000000 #分配256M内存

WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.

解决方法:警告:过量使用内存设置为0!在低内存环境下,后台保存可能失败。为了修正这个问题,请在/etc/sysctl.conf 添加一项 'vm.overcommit_memory = 1' ,然后重启(或者运行命令'sysctl vm.overcommit_memory=1' )使其生效。

当启动的时候没有任何信息,表明启动成功。也可以使用 "netstat -tnl" 查看6379端口是否启动。

4、开启和关闭 redis

redis-server /usr/local/redis-2.6.9/redis.conf 开启,注:需要指定 redis 的配置文件

pkill redis-server 停止 redis redis-cli shutdown 停止 redis

5、redis.conf 的参数信息

关于redis及其参数信息可参考本站《

6、编译 PHPredis

rush:bash;"> unzip PHPredis-master.zip cd PHPredis-master /usr/local/PHP/bin/PHPize ./configure –with-PHP-config=/usr/local/PHP/bin/PHP-config make && make install

修改 PHP.ini 文件。加载 redis.so 模块,重启 Apache !

更多关于PHP相关内容感兴趣的读者可查看本站专题:《》、《》、《》、《》、《》、《》、《》、《》、《》及《

希望本文所述对大家PHP程序设计有所帮助。

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...