ddxiami

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 2520|回复: 0

[web服务] redis-2.6.13编译安装

[复制链接]
发表于 2013-5-22 16:47:48 | 显示全部楼层 |阅读模式
#基于PHP的基础环境已配置
#配置tcl8.5
tar zxvf tcl8.5.12-src.tar.gz
cd tcl8.5.12/unix
./configure --prefix=/usr/local/tcl8.5
make && make install
cp /usr/local/tcl8.5/bin/tclsh8.5 /usr/bin/

#解压
tar xzvf redis-2.6.13.tar.gz
cd redis-2.6.13
make
make test
make install

#启动脚本
mkdir /etc/redis
cp redis-2.6.13/redis.conf /etc/redis

#建立守护进程
vi /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/bin/redis-server"
prog=$(basename $redis)

REDIS_CONF_FILE="/etc/redis/redis.conf"

[ -f /etc/sysconfig/redis ] && . /etc/sysconfig/redis

lockfile=/var/lock/subsys/redis

start() {
    [ -x $redis ] || exit 5
    [ -f $REDIS_CONF_FILE ] || exit 6
    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
==========================================================================

#设置开机启动
chmod +x /etc/init.d/redis
chkconfig redis on

#启动redis服务
service redis restart

#redis.so客户端暂时不用

#安装phpredis模块
tar xzvf phpredis-2.2.2-84-g6d244bb.tar.gz
cd nicolasff-phpredis-6d244bb/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install

#修改php.ini文件,添加redis.so
cat >> /usr/local/php/etc/php.ini << "EOF"

[redis]
extension=redis.so
EOF

#重启php-fpm
service php-fpm restart
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|技术文档库 ( 闽ICP备15017263号-2 )|网站地图

GMT+8, 2025-5-18 18:07 , Processed in 0.035345 second(s), 16 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表