PHP Startup redis: Unable to initialize module

来源:互联网 发布:蒙特卡洛算法 matlab 编辑:程序博客网 时间:2024/05/02 01:01

最近在做php连接redis的实验,遇到一个问题语法是php代码直接使用php命令来测试是没有问题的。使用lnmp环境也是没有问题的,但是lamp就是不可以,最后查看http的日志终于找到问题所在了。

php测试代码如下:

<?php session_start(); if (!isset($_SESSION['TEST'])) { $_SESSION['TEST'] = time(); } $_SESSION['TEST3'] = time(); print $_SESSION['TEST']; print "<br><br>"; print $_SESSION['TEST3']; print "<br></br><br></br>"; print session_id(); ?>

http log:

[Sun Apr 24 23:06:47 2016] [notice] SIGHUP received.  Attempting to restartPHP Warning:  PHP Startup: redis: Unable to initialize module\nModule compiled with module API=20121212\nPHP    compiled with module API=20100525\nThese options need to match\n in Unknown on line 0[Sun Apr 24 23:06:47 2016] [notice] Apache/2.2.29 (Unix) PHP/5.4.45 configured -- resuming normal operations[Sun Apr 24 23:24:21 2016] [notice] SIGHUP received.  Attempting to restartPHP Warning:  PHP Startup: redis: Unable to initialize module\nModule compiled with module API=20121212\nPHP    compiled with module API=20100525\nThese options need to match\n in Unknown on line 0[Sun Apr 24 23:24:21 2016] [notice] Apache/2.2.29 (Unix) PHP/5.4.45 configured -- resuming normal operations

分析:

日志非常明显的说明当时编译php使用的api为“API=20100525”,而redis编译使用的api为“API=20121212”

ps:由于之前多次安装过不同版本的apache,所以我自己都不清楚当时编译php时使用的那个版本了(有点尴尬:()

解决方法如下:

使用yum安装一个高版本的httpd,然后重新启动一个httpd服务就可以了(把配置文件和webroot更新一下)。

测试:

curl -x 127.1.1.1:80 www.cf.com/session.php 1461514249<br><br>1461514249<br></br><br></br>r05vrgop80r2f75t91ss1a2lv5 



0 0