今天把自己的環境安裝了最新的PHP5.4.8,結果在與Memcache時出現了不相容問題,結過反覆調度總結了不相容的原因與解決辦法。
emcache(sudo pecl install memcache)PHP擴充,編譯後memcache.so在/usr/lib/php5/20090626/中,在PHP.ini添加好extension,重啟phpfpm(不是重啟nginx),出現下面的錯誤資訊:
| 代碼如下 |
複製代碼 |
Gracefully shutting down php-fpm . done Starting php-fpm [25-Oct-2012 12:04:02] NOTICE: PHP message: PHP Warning: PHP Startup: memcache: Unable to initialize module Module compiled with module API=20090626 PHP compiled with module API=20100525 These options need to match |
編譯PHP使用的PHP核心版本是20100525,而Pecl裡面的Memcache是使用20090626版本編譯的,版本不一致導致PHP無法啟用memcache.so庫。解決方案是卸載掉Pecl方式安裝的Memcache,去pecl.php.net/package/memcache下載源碼包自己編譯。
| 代碼如下 |
複製代碼 |
##卸載memcache sudo pecl uninstall memcache phpize ./configure --enable-memcache --with-php-conf=/usr/local/php/bin/php-config make make install |
啟動memcached服務:memcached -d -m 256 -p 11211。測試指令碼:OK。
| 代碼如下 |
複製代碼 |
$mem = new Memcache; $mem->connect('127.0.0.1',11211); $mem->set('feiyan','blog'); var_dump( $mem->get('feiyan') ); |
http://www.bkjia.com/PHPjc/629830.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/629830.htmlTechArticle今天把自己的環境安裝了最新的PHP5.4.8,結果在與Memcache時出現了不相容問題,結過反覆調度總結了不相容的原因與解決辦法。 emcache(sudo...