PHP5.4.X與Memcache不相容問題解決方案_PHP教程

來源:互聯網
上載者:User
今天把自己的環境安裝了最新的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...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.