最近在做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 restart PHP 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 restart PHP 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”
立即学习“PHP免费学习笔记(深入)”;
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
以上就介绍了PHP Startup redis: Unable to initialize module,包括了initialize,startup方面的内容,希望对PHP教程有兴趣的朋友有所帮助。
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号