首页 > 系统 > Linux > 正文

linux系统nginx php-fpm安装php memcache扩展

2024-08-27 23:55:23
字体:
来源:转载
供稿:网友
  下面来看一篇关于linux系统nginx php-fpm安装php memcache扩展教程,当然有不少办法可以安装memcache的插件不过如果你使用了php-fpm 和nginx驱动php采用那些sudo apt-get install php5-memcache可能就不好用了.
 
  说说如果你把php手动安装在特别目录的情况下如何配置memcache php调用吧,上下文参考我写的php-fpm安装那篇博客吧,代码如下:
 
  cd /data1/server/php-cgi/bin
 
  进入php安装好的目录bin下执行如下代码:
 
  ./pecl install memcache
  downloading memcache-2.2.6.tgz …
  Starting to download memcache-2.2.6.tgz (35,957 bytes)
  ……….done: 35,957 bytes
  11 source files, building
  WARNING: php_bin /data1/server/php-cgi/bin/php appears to have a suffix -cgi/bin/php, but config variable php_suffix does not match
  running: phpize
  Configuring for:
  PHP Api Version: 20100412
  Zend Module Api No: 20100525
  Zend Extension Api No: 220100525
  Cannot find autoconf. Please check your autoconf installation and the
  $PHP_AUTOCONF environment variable. Then, rerun this script.
  
  ERROR: `phpize’ failed
  少个东西没装啊,开始装它:sudo apt-get install autoconf
 
  显示出成功了.
 
  Build process completed successfully
  Installing ‘/data1/server/php-cgi/lib/php/extensions/no-debug-non-zts-20100525/memcache.so’
  install ok: channel://pecl.php.net/memcache-2.2.6
  configuration option “php_ini” is not set to php.ini location
  You should add “extension=memcache.so” to php.ini
  安装提示把extension=memcache.so 这句话加入php.ini就成功了,测试一下,代码如下:
 
  <?php
  $mem = new Memcache;
  $mem->connect(’211.144.xx.xx’, 11211);
  $mem->set(‘key’, ‘This is a test!’, 0, 60);
  $val = $mem->get(‘key’);
  echo $val;  //phpfensi.com
  ?>
  是不是成功了.

(编辑:武林网)

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表