nginx+php+memcache Fatal error: Class 'Memcache' not found

來源:互聯網
上載者:User

安裝過程:

(nginx+php已經安裝完成,僅寫與memcache相關步驟)

[root@zz src]# yum install libevent libevent-devel

[root@zz src]# wget http://pecl.php.net/get/memcache-2.2.5.tgz

[root@zz src]# tar zxvf memcache-2.2.5.tgz

[root@zz src]# cd memcache-2.2.5

[root@zz src]# ./configure --enable-memcache --with-php-config=/opt/php/bin/php-config

[root@zz src]# make && make install

完成後會有“Installing shared extensions: /opt/php/lib/php/extensions/no-debug-non-zts-20090626”提示,最後這個值會不一樣

[root@zz src]# cd /opt/php/etc

[root@zz src]# vi php.ini

 819行: extension_dir = "/opt/php/lib/php/extensions/no-debug-non-zts-20090626"#(貌似是)

添加:extension=memche.so

[root@zz src]# vi /var/www/html/test.php

<?php
$mem = new memcache;
$mem->connect ('127.0.0.1', 11211);
$mem->set('test','hello world!', 0, 12);
$val = $mem->get('test');
echo $val;
?>

在瀏覽器中輸入:localhost:8080,

so,問題來了,無法訪問,查看nginx日誌:


2013/07/09 18:18:13 [error] 3855#0: *84498 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Class 'memcache' not found in /var/www/tjtct/test.php on line 2" while reading response header from upstream, client: 192.168.1.193, server: 192.168.1.242, request: "GET /test.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "192.168.1.242"

解決辦法:

重啟php-fpm

/etc/ini.d/php-fpm restart


重新瀏覽,OK,hello world。 出來了

搞定,結束

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.