Home >php教程 >php手册 >不重新编译php安装redis扩展

不重新编译php安装redis扩展

WBOY
WBOYOriginal
2016-06-06 20:13:43997browse

一、所需资源 需要下载一个php的redis扩展源码,可事先到这来下载。https://github.com/nicolasff/phpredis/archive/master.zip 二、安装 1、先解压 1 2 3 ? unzip phpredis - master . zip ? 2、安装 注:请先找到php的安装目录,示例是在 /usr/local/php

一、所需资源

需要下载一个php的redis扩展源码,可事先到这来下载。https://github.com/nicolasff/phpredis/archive/master.zip

二、安装

1、先解压

1

2

3

?

unzip phpredis-master.zip

?

2、安装

注:请先找到php的安装目录,示例是在/usr/local/php

1

2

3

4

5

6

7

?

cd phpredis-master

/usr/local/php/bin/phpize

./configure-with-php-config=/usr/local/php/bin/php-config

make

make install

?

3、修改php.ini

找到php.ini, 添加extension=redis.so
重启 apache 或者 nginx 或者 php-fpm

三、测试

测试比较简单

1

2

3

4

5

6

?

$redis=newRedis();

$redis->connect(127.0.0.1,6379);

$redis->set(test,'hello world!);

echo$redis->get(test);

?

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn