一:redis安装
Download, extract and compile Redis with:

$ wget http://download.redis.io/releases/redis-3.0.4.tar.gz
    $ tar xzf redis-3.0.4.tar.gz
    $ cd redis-3.0.4
    $ make

编译完成将:redis-server  redis-cli 和上级目录redis.conf  复制到 /usr/local/redis目录下 并将daemonize改为yes

启动redis: ./redis-server redis.conf

The binaries that are now compiled are available in the src directory. Run Redis with:

$ redis-server

You can interact with Redis using the built-in client:

$ redis-cli

redis> set name ruanqin
OK
redis> get name
"ruanqin"
这里无法启动:

错误信息如下:

PHP Warning: php Startup: redis: Unable to initialize module
Module compiled with module API=20050922
PHP compiled with module API=20090626
These options need to match in Unknown on line 0

首先先说下这种错误出现的原因:

执行编译源码包执行phpize的版本与当前php环境中phpize的版本不一致造成的,也有可能和你切换的php版本有关系,我就是切换版本之后重新安装的解决办法:

1、删除编译过的源码包phpredis-master以及对应目录中的redis.so重新解压phpredis-master

2、检测/usr/sbin目录下是否存在php php-config php-cgi phpize文件,如果存在删除这些文件 重新建立对应的软连接到这个目录。

ln -s php /usr/local/php/bin/php
ln -s php-cgi /usr/local/php/bin/php-cgi
ln -s php-config /usr/local/php/bin/php-config
ln -s phpize /usr/local/php/bin/phpize

以上目录请以php的当前安装目录为准。

3、重新进入phpredis-master目录进行安装即可。

More:http://www.redis.io/download

二、php扩展:
更多版本:http://pecl.php.net/package/redis

wget http://pecl.php.net/get/redis-2.2.5.tgz
    #解压
    tar zxvf redis-2.2.5.tgz
    #进入安装目录
    cd redis-2.2.5
    /usr/local/php/bin/phpize
    #配置
    ./configure --with-php-config=/usr/local/php/bin/php-config
    #编译安装
    make && make install

安装完成之后,出现下面的安装路径
/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/

配置php支持
#编辑配置文件,在最后一行添加以下内容

vim /usr/local/php/etc/php.ini
    extension="redis.so"

这个时候phpinfo()就可以看到redis扩展了。

redis 服务器重启自启动命令

在/etc/init.d/目录下创建redis  复制内容

#!/bin/sh
#
# redis - this script starts and stops the redis-server daemon
#
# chkconfig: - 85 15
# description: Redis is a persistent key-value database
# processname: redis-server
# config: /etc/redis/redis.conf
# config: /etc/sysconfig/redis
# pidfile: /var/run/redis.pid # Source function library.
. /etc/rc.d/init.d/functions # Source networking configuration.
. /etc/sysconfig/network # Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0 redis="/usr/local/redis/redis-server"
prog=$(basename $redis) REDIS_CONF_FILE="/usr/local/redis/redis.conf" [ -f /etc/sysconfig/redis ] && . /etc/sysconfig/redis lockfile=/var/lock/subsys/redis start() {
echo "start test!"
[ -x $redis ] || exit 5
[ -f $REDIS_CONF_FILE ] || exit 6
echo "test successful!"
echo -n $"Starting $prog: "
daemon $redis $REDIS_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
} stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
} restart() {
stop
start
} reload() {
echo -n $"Reloading $prog: "
killproc $redis -HUP
RETVAL=$?
echo
} force_reload() {
restart
} rh_status() {
status $prog
} rh_status_q() {
rh_status >/dev/null 2>&1
} case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
exit 2
esac

最后记得给他个权限 755就可以了

特殊情况下redis启动失败可以加个脚本文件:

#!/bin/bash
# Source function library.
. /etc/rc.d/init.d/functions # Source networking configuration.
. /etc/sysconfig/network ret=$(ps aux|grep redis|awk '{print $2,$11}'|grep redis|head -|awk '{print $1}') if [ -z $ret ]
then
echo 'ready to start'
echo "service redis start"
eval "service redis start"
else
echo 'fk,'
fi

crontab 中写入:     */1 * * * * /bin/bash /www/shell/redis.sh > /var/log/redis_err.log 2>&1 &

php切换版本之后 redis 安装使用的更多相关文章

  1. swoole1.8.0+版本异步redis安装(本实例为swoole1.8.10版本)详解

    Swoole-1.8.0+版本增加了对异步Redis客户端的支持,基于redis官方提供的hiredis库实现.Swoole提供了__call魔术方法,来映射绝大部分Redis指令(本次安装实例为sw ...

  2. 【微软版本】redis 安装启动及设置密码<windows>

    redis 安装启动及设置密码<windows>   redis 1. 安装 1.1 下载解压包,直接解压到任意路径下即可 windows下载地址:ttps://github.com/MS ...

  3. lnmp 切换PHP版本,并且安装swoole

    lnmp 切换php版本 进入 lnmp 安装的目录,进入install.sh 的目录执行: sudo ./install.sh mphp 备注: find / -name install.sh 备注 ...

  4. Redis windows版本资源与安装

    这里提供一个windows版本的Redis百度云资源 链接: https://pan.baidu.com/s/19JY_d_J87n98OeAHK9qI4A 密码: d6dq 1,GitHub下载地址 ...

  5. 切换node版本,node-sass安装报错

    一.问题 经常在开发过程中,会遇到切换node环境的情况,这时候切换之后,npm安装不了node-sass,有可能是之前把node-sass安装地址修改了,导致翻墙翻不了,所以安装不了. 二.解决 1 ...

  6. Redis安装配置与Jedis访问数据库

    一.NOSQL概要 NoSQL(NoSQL = Not Only SQL ),意即“不仅仅是SQL”,泛指非关系型的数据库.NoSQL数据库的四大分类 键值(Key-Value)存储数据库 这一类数据 ...

  7. Linux下Redis安装与PHP扩展(PHP7适用)

    一,软件准备 #redis wget http://download.redis.io/releases/redis-3.0.7.tar.gz #phpredis 非php7使用 下载后文件名为:ph ...

  8. Redis安装及HA(High Availability)配置

    Redis是一种内存数据库,以KEY-VALUE(即键值对)的形式存储数据.这篇文章主要介绍的是Redis安装及配置,所以不对Redis本身作详细介绍了. 下载: http://redis.io/do ...

  9. Redis、Redis+sentinel安装(Ubuntu 14.04下Redis安装及简单测试)

    Ubuntu下Redis安装两种安装方式: 1.apt-get方式 步骤: 以root权限登录,切换到/usr目录下. 接下来输入命令,apt-get install redis-server,如图: ...

随机推荐

  1. Write a program that gives count of common characters presented in an array of strings..(or array of

    转自出处 Write a program that gives count of common characters presented in an array of strings..(or arr ...

  2. http ssl

    http ssl

  3. 修改数据表的字符集为utf8mb4

    修改数据表的字符集为utf8mb4

  4. 在Ubuntu 12.04 LTS下成功访问Windows域共享(mount //192.168.1.102/share -o user=DOMIAN\\user,pass=passwd /mnt)

    Ubuntu 12.04 LTS下成功访问Windows域共享: 1,在命令行模式下 mount //192.168.1.102/share -o user=DOMIAN\\user,pass=pas ...

  5. ZOJ 1871:Steps

    Steps Time Limit: 2 Seconds      Memory Limit: 65536 KB One steps through integer points of the stra ...

  6. [NOI2018]冒泡排序

    https://www.zybuluo.com/ysner/note/1261482 题面 戳我 \(8pts\ n\leq9\) \(44pts\ n\leq18\) \(ex12pts\ q_i= ...

  7. uva10870

    https://vjudge.net/problem/UVA-10870 裸的矩阵快速幂 注意系数矩阵在前面 因为系数矩阵为d*d 方程矩阵为d * 1 放反了就是d * 1 d * d 不符合矩阵乘 ...

  8. 大神给你分析HTTPS和HTTP的区别(转)

    http://www.php100.com/html/it/biancheng/2015/0209/8582.html 今天在做雅虎的时候,发现用第三方工具截取不到客户端与服务端的通讯,以前重来没碰到 ...

  9. E20170610-hm

    presence  n. 出席; 仪表; 风度; 鬼魂,神灵; defence   n. 防御; 辩护; 防御工事; 后卫; phyle  n. 种族,宗族; race  n. 赛跑; 民族; 人种; ...

  10. 清北考前刷题day4早安

      LI /* 没有考虑次大值有大于一个的情况 */ #include<iostream> #include<cstdio> #include<cstring> # ...