Centos7.0安装redis

来源:互联网 发布:php高级工程师证书 编辑:程序博客网 时间:2024/05/20 01:08
[root@localhost /]# yum install gcc-c++[root@localhost /]# wget http://download.redis.io/releases/redis-2.8.17.tar.gz[root@localhost /]# tar xzf redis-2.8.17.tar.gz[root@localhost /]# cd redis-2.8.17[root@localhost /]# makemake完后 redis-2.8.17目录下会出现编译后的redis服务程序redis-server,还有用于测试的客户端程序redis-cli,两个程序位于安装目录 src 目录下。下面启动redis服务 :[root@localhost /]# cd src[root@localhost /]# ./redis-server &[root@localhost src]# ./redis-cli127.0.0.1:6379> set foo barOK127.0.0.1:6379> get foo"bar"127.0.0.1:6379> 以上测试如果不出任何问题这样你的linux服务器上的redis就安装ok!接下来安装php_redis.dll扩展让php支持redis[root@localhost /]# yum install php-devel[root@localhost /]# wget https://github.com/phpredis/phpredis/archive/2.2.4.tar.gz[root@localhost /]# tar zxf 2.2.4.tar.gz[root@localhost /]# cd phpredis-2.2.4 [root@localhost phpredis-2.2.4]# /usr/bin/phpize    #phpize执行文件的路径Configuring for:PHP Api Version:         20100412Zend Module Api No:      20100525Zend Extension Api No:   220100525[root@localhost phpredis-2.2.4]# ./configure --with-php-config=/usr/bin/php-config[root@localhost phpredis-2.2.4]# make && make install如果你上述操作没有任何错误你的php-redis扩展就安装完成!接下来让php加载redis扩展[root@localhost /]# vi /etc/php.ini写入extension=redis.so[root@localhost /]# systemctl restart httpd访问phpinfo() 查看redis版本号及其他信息[root@localhost html]# vim redis.php<?php$redis = new Redis();$redis->connect('127.0.0.1', 6379);$redis->set('key','val');echo $redis->get('key');?>http://ip/redis.php


0 0
原创粉丝点击