8244 发表于 2015-11-18 11:01:05

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

  安装过程:
  (nginx+php已经安装完成,仅写与memcache相关步骤)
  # yum install libevent libevent-devel

  # wget http://pecl.php.net/get/memcache-2.2.5.tgz

  # tar zxvf memcache-2.2.5.tgz

  # cd memcache-2.2.5

  # ./configure --enable-memcache --with-php-config=/opt/php/bin/php-config

  # make && make install
  完成后会有“Installing shared extensions: /opt/php/lib/php/extensions/no-debug-non-zts-20090626”提示,最后这个值会不一样
  # cd /opt/php/etc

  # vi php.ini

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

  添加:extension=memche.so
  # 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 3855#0: *84498 FastCGI sent in stderr: &quot;PHP message: PHP Fatal error:Class 'memcache' not found in /var/www/tjtct/test.php on line 2&quot; while reading response header from upstream, client:192.168.1.193, server: 192.168.1.242, request: &quot;GET /test.php HTTP/1.1&quot;, upstream: &quot;fastcgi://127.0.0.1:9000&quot;, host: &quot;192.168.1.242&quot;

  解决办法:
  重启php-fpm
  /etc/ini.d/php-fpm restart
  

  重新浏览,OK,hello world! 出来了
  搞定,结束
         版权声明:本文为博主原创文章,未经博主允许不得转载。
页: [1]
查看完整版本: nginx+php+memcache Fatal error: Class 'Memcache' not found