wget
tar xvzf redis-stable.tar.gz
cd redis-stable
make
前面3步应该没有问题,主要的问题是执行make的时候,出现了异常。
异常一:
make[2]: cc: Command not found
异常原因:没有安装gcc
解决方案:yum install gcc-c++
异常二:
zmalloc.h:51:31: error: jemalloc/jemalloc.h: No such file or directory
异常原因:一些编译依赖或原来编译遗留出现的问题
解决方案:make distclean。清理一下,然后再make。
在make成功以后,需要make test。在make test出现异常。
异常一:
couldn't execute "tclsh8.5": no such file or directory
异常原因:没有安装tcl
解决方案:yum install -y tcl。或者:
- wget http://downloads.sourceforge.net/tcl/tcl8.5.10-src.tar.gz
- tar xzvf tcl8.5.10-src.tar.gz
- cd tcl8.5.10/unix/
- ./configure
- make&&make install
运行make test
#cd /home/sandea/redis-stable
#make test
在make test成功以后,make install
#make install
测试通过后安装,安装后会自动把redis-server,redis-cli,redis-benchmark,redis-check-aof,redis-check-dump复制到/usr/local/bin目录下
编辑redis.conf文件
#mkdir /etc/redis #cp redis.conf /etc/redis/redis.conf #vi /etc/redis/redis.conf
daemonize yes
pidfile /var/run/redis.pid
logfile /etc/redis/redis.log
编写自init.d脚本
#vi /etc/init.d/redis
内容如下:
###########################
#chkconfig: 2345 10 90#description: Start and Stop redisPATH=/usr/local/bin:/sbin:/usr/bin:/binREDISPORT=6379EXEC=/usr/local/bin/redis-serverREDIS_CLI=/usr/local/bin/redis-cliPIDFILE=/var/run/redis.pidCONF="/etc/redis/redis.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 if [ "$?"="0" ] then echo "Redis is running..." fi ;; stop) if [ ! -f $PIDFILE ] then echo "$PIDFILE does not exist, process is not running" else PID=$(cat $PIDFILE) echo "Stopping ..." $REDIS_CLI -p $REDISPORT SHUTDOWN while [ -x ${PIDFILE} ] do echo "Waiting for Redis to shutdown ..." sleep 1 done echo "Redis stopped" fi ;; restart|force-reload) ${0} stop ${0} start ;; *) echo "Usage: /etc/init.d/redis {start|stop|restart|force-reload}" >&2 exit 1esac##############################保存,给redis授权:
#chmod +x /etc/init.d/redis
设置开机自动启动服务:
#chkconfig redis on
启动服务:
#service redis start
停止服务:
#service redis stop
调试:
#redis-cli -h 127.0.0.1 -p 6379
#set hello "word"
#get hello
"word"
2.安装PhpRedis
phpize
phpredis属于php扩展,所以需要phpize,如果你的服务器没有安装phpize,要先安装
-
yum install php-devel
下载源码包
直接用wget好了
-
wget https://github.com/nicolasff/phpredis/archive/master.zip
unzip
下面要解压zip文件,首先,你,要,有个,unzip....
#安装了这么多的软件,想想也该知道怎么装这个东西了吧
-
yum install unzip
-
unzip master.zip
编译
下面正式开始编译php扩展
-
[root@localhost phpredis-master]# phpize
-
Configuring for:
-
PHP Api Version: 20090626
-
Zend Module Api No: 20090626
-
Zend Extension Api No: 220090626
#2.配置环境
-
./configure --with-php-config=/usr/local/php/bin/php-config --enable-vld
#3.编译
-
make && make install
-
#编译完成
-
Build complete.
-
Don't forget to run 'make test'.
-
-
Installing shared extensions: /usr/lib/php/modules/
6.cp /home/tools/phpredis-master/modules/redis.so /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/redis.so
修改php.ini
-
[root@localhost phpredis-master]# vi /etc/php.ini
添加下面的扩展
-
extension=redis.so
重启服务器
-
-
[root@localhost modules]# service php-fpm restart
-
停止 httpd: [确定]
-
正在启动 httpd: [确定]
-