万网云翔主机centos系统下为PHP安装扩展memcache

3 篇文章 0 订阅
2 篇文章 0 订阅
 php扩展memcache的作用是为了支持memcached数据库缓存服务器,下面是安装方法。
1、下载并解压memcache文件
wget -c http://pecl.php.net/get/memcache-3.0.6.tgz
tar xzvf memcache-3.0.6.tgz
cd memcache-3.0.6
2、执行phpize扩展安装程序,假设phpzie的路径为/usr/local/php/bin/phpize,具体的路径得根据自己的环境修改。
/var/www/php5/bin/phpize

3、开始安装扩展memcache

./configure --enable-memcache --with-php-config=/var/www/php5/bin/php-config --with-zlib-dir
make && make install

安装完成后,提示

Installing shared extensions:     /var/www/php5/lib/php/extensions/no-debug-non-zts-20060613/
4、最后修改php.ini文件,在zend之前加入如下代码。
[memcache]
extension_dir = "/var/www/php5/lib/php/extensions/no-debug-non-zts-20060613/"
extension=memcache.so

到这里就安装结束了,重新加载php.ini配置后,打开phpinfo()看下是不是有memcache。

附php的memcache测试代码:

<?php
$memcache = new Memcache;
$memcache->connect('127.0.0.1', 11211) or die ("Could not connect");
$version = $memcache->getVersion();
echo "Server's version: ".$version."\n";
$tmp_object = new stdClass;
$tmp_object->str_attr = 'test';
$tmp_object->int_attr = 123;
$memcache->set('key', $tmp_object, false, 10) or die ("Failed to save data at the server");
echo "Store data in the cache (data will expire in 10 seconds)\n";
$get_result = $memcache->get('key');
echo "Data from the cache:\n";
var_dump($get_result);
?>


万网云翔主机centos系统下安装memcached

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值