标签:
首先安装redis扩展 https://github.com/phpredis/phpredis 下载
http://redis.io/download 服务软件
cd到软件存放目录
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
会得到
/usr/local/php/lib/php/extensions/no-debug-zts-20131226/redis.so
cp php.ini-production /etc/php.ini这个是配置文件路径
如果你没有在编译的时候指定php的配置文件的路径,默认是/etc/下面
如果你不知道在哪,phpinfo的信息
Configuration File (php.ini) Path | /etc |
Loaded Configuration File | /etc/php.ini |
vi /etc/php.ini
加一句
extension=redis.so
重启nginx服务器和php-fpm
/usr/local/php/bin/php -m查看加载了redis模块
安装redis-server
tar -zxvf redis-2.8.19.tar.gz
cd redis-2.8.19
新版的貌似不能./configure --prefix=路径了
make
make install
cp redis.conf /etc/
redis-server /etc/redis.conf
是前台运行,启动要改为后台运行
vi /etc/redis.conf
daemonize yes
/usr/local/src/redis/utils/redis_init_script 是脚本文件
现在把redis做为服务
ls
mkdir /etc/redis/
做为配置文件的路径
cp /usr/local/src/redis-2.8.19/utils/redis_init_script /etc/rc.d/init.d/redis
chkconfig --add redis
加入服务失败
vi /etc/rc.d/init.d/redis
#!/bin/bash #chkconfig: 2345 80 90 # Simple Redis init.d script conceived to work on Linux systems # as it does use of the /proc filesystem. REDISPORT=6379 EXEC=/usr/local/redis/bin/redis-server CLIEXEC=/usr/local/redis/bin/redis-cli PIDFILE=/var/run/redis_${REDISPORT}.pid CONF="/etc/redis/${REDISPORT}.conf" case "$1" in start) if [ -f $PIDFILE ] then echo "$PIDFILE exists, process is already running or crashed" else echo "Starting Redis server..." $EXEC $CONF & fi ;; stop) if [ ! -f $PIDFILE ] then echo "$PIDFILE does not exist, process is not running" else PID=$(cat $PIDFILE) echo "Stopping ..." $CLIEXEC -p $REDISPORT shutdown while [ -x /proc/${PID} ] do echo "Waiting for Redis to shutdown ..." sleep 1 done echo "Redis stopped" fi ;; *) echo "Please use start or stop as first argument" ;; esac
这个是修改好的配置文件
原文件是没有以下第2行的内容的,
$EXEC $CONF &
cp /usr/local/src/redis-2.8.19/redis.conf /etc/redis/6379.conf
chkconfig --add redis
chkconfig redis on
service redis start
redis-cli
vi /etc/redis/6379.conf
daemonize yes
就oK,查看redis服务是不是启动
netstat -tnlp
就OK了
标签:
原文地址:http://www.cnblogs.com/zx-admin/p/4316045.html