最近在做php串連redis的實驗,遇到一個問題文法是php代碼直接使用php命令來測試是沒有問題的。使用lnmp環境也是沒有問題的,但是lamp就是不可以,最後查看http的日誌終於找到問題所在了。
php測試代碼如下:
"; print $_SESSION['TEST3']; print "
"; 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
1461514249
r05vrgop80r2f75t91ss1a2lv5
以上就介紹了PHP Startup redis: Unable to initialize module,包括了initialize,startup方面的內容,希望對PHP教程有興趣的朋友有所協助。