以前一直遇到,Module compiled with module API=20090626这个坑问题!!!php
NOTICE: PHP message: PHP Warning: PHP Startup: redis: Unable to initialize module Module compiled with module API=20090626 PHP compiled with module API=20131226 These options need to match in Unknown on line 0
当服务器中安装了2个以上的php环境时会出现以上错误,这是因为phpize编译的版本不一致html
问题详解,然并卵。。。http://blog.csdn.net/justin_bkdrong/article/details/46738629nginx
改extension_dir,效果不明显。。。https://segmentfault.com/q/1010000000603251git
后来按照下面的步骤安装成功!!!github
开始在 PHP 中使用 Redis 前, 咱们须要确保已经安装了 redis 服务及 PHP redis 驱动,且你的机器上能正常使用 PHP。 接下来让咱们安装 PHP redis 驱动:下载地址为:https://github.com/phpredis/phpredis/releases。redis
$ wget https://github.com/phpredis/phpredis/archive/2.2.4.tar.gz
如下操做须要在下载的 phpredis 目录中完成:shell
$ cd phpredis-2.2.7 # 进入 phpredis 目录 $ /usr/local/php/bin/phpize # php安装后的路径,写全phpize的路径
$ ./configure --with-php-config=/usr/local/php/bin/php-config $ make && make install #配置时 要将php-config的路径附上
若是你是 PHP7 版本,则须要下载指定分支:apache
git clone -b php7 https://github.com/phpredis/phpredis.git
vi /usr/local/php/lib/php.ini
增长以下内容:segmentfault
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-zts-20090626" extension=redis.so
安装完成后重启php-fpm 或 apache。查看phpinfo信息,就能看到redis扩展。服务器
cd /usr/local/nginx/html touch redis.php vi redis.php
编辑
<?php //链接本地的 Redis 服务 $redis = new Redis(); $redis->connect('127.0.0.1', 6379); echo "Connection to server sucessfully"; echo "Server is running: " . $redis->ping(); //设置 redis 字符串数据 $redis->set("tutorial-name", "Redis tutorial"); // 获取存储的数据并输出 echo "Stored string in redis:: " . $redis->get("tutorial-name"); ?>
保存,!wq
X-shell新建一个链接,开启redis服务
/usr/local/src/redis-3.0.6/src/redis-server
访问 IP/redis.php
参考:http://www.runoob.com/redis/redis-php.html