===============redis 安装==========================php
直接yum 安装的redis 不是最新版本git
yum install redis
若是要安装最新的redis,须要安装Remi的软件源,官网地址:http://rpms.famillecollet.com/github
yum install -y http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
而后可使用下面的命令安装最新版本的redis:redis
yum --enablerepo=remi install redis
安装完毕后,便可使用下面的命令启动redis服务apache
systemctl start redis
redis安装完毕后,咱们来查看下redis安装时建立的相关文件,以下:vim
rpm -qa |grep redis
rpm -ql redis
查看redis版本:centos
redis-cli --version
设置为开机自动启动:服务器
systemctl enable redis.service
Redis开启远程登陆链接,redis默认只能localhost访问,因此须要开启远程登陆。解决方法以下:php7
在redis的配置文件/etc/redis.conf中ui
将bind 127.0.0.1 改为了 bind 0.0.0.0
而后要配置防火墙 开放端口6379
链接redis
redis-cli
=================php-redis 拓展安装===================
使用git clone下载git上的phpredis扩展包
[root@VM_103_117_centos ]#git clone https://github.com/phpredis/phpredis.git
到了这一步,咱们要使用安装php时生成的phpize来生成configure配置文件,
//具体用哪一个要取决于你的phpize文件所在的目录,这时你应该用 whereis phpize 来查看路径
[root@VM_103_117_centos phpredis]# whereis phpize
phpize: /usr/bin/phpize /usr/share/man/man1/phpize.1.gz
这里代表路径为/usr/bin/phpize,而后执行:
[root@VM_103_117_centos phpredis]# /usr/bin/phpize
Can't find PHP headers in /usr/include/php
The php-devel package is required for use of this command.
这里报错了,缘由是没有安装好php-devel,因为我是使用的php7.0因此执行如下命令:
[root@VM_103_117_centos phpredis]#yum -y install php70w-devel
而后再次执行:
[root@VM_103_117_centos phpredis]# /usr/bin/phpize
Configuring for:
PHP Api Version: 20151012
Zend Module Api No: 20151012
Zend Extension Api No: 320151012
执行完上一步,咱们就有了 configure 配置文件了,接下来配置
[root@VM_103_117_centos phpredis]#./configure
或者执行
[root@VM_103_117_centos phpredis]#./configure --with-php-config=/usr/bin/php-config
接下来是编译安装
[root@VM_103_117_centos phpredis]#make
[root@VM_103_117_centos phpredis]# make install
Installing shared extensions: /usr/lib64/php/modules/
配置php的配置文件php.ini(具体放在那里能够用 whereis php.ini 来查看),个人配置文件php.ini在/etc/下
[root@VM_103_117_centos phpredis]#vim /etc/php.ini
加入下面几行:
[redis]
extension_dir =/usr/lib64/php/modules/
extension = redis.so
redis.so文件的路径能够在make install的时候看到
重启apache服务器,使配置生效
[root@VM_103_117_centos phpredis]#systemctl restart httpd.service
重启以后咱们打开info.php,已经能够看到redis的扩展信息了