欢迎来到代码驿站!

PHP代码

当前位置:首页 > 软件编程 > PHP代码

PHP安装memcache扩展的步骤讲解

时间:2021-02-09 14:35:42|栏目:PHP代码|点击:

PHP 5.6.23,查询目前最稳定的版本是memcache-2.2.7。

1.下载并解压缩。

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

tar zxvf memcache-2.2.7.tgz

2. 编译。根据实际情况使用phpize和php-config。

[root@www memcache-2.2.7]# /usr/local/php/bin/phpize
Configuring for:
PHP Api Version:     20131106
Zend Module Api No:   20131226
Zend Extension Api No:  220131226
[root@www memcache-2.2.7]# ./configure --enable-memcache --with-php-config=/usr/local/php/bin/php-config

3.安装。make;make install

[root@www memcache-2.2.7]# make install
Installing shared extensions:   /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/

4.修改php.ini(添加 extension=memcache.so)并重启php-fpm。

下面在linux下测试一下php与memcache的连接性。假设memcached服务器侧就在127.0.0.1。生成op_mem.php文件,代码如下:

<?php
  $memcache = new Memcache;
  $memcache->connect('127.0.0.1',11211) or die("Could not connect Mc server");
  $memcache->set('key','oldboy book');
  $get= $memcache->get('key');
  echo $get;
?>

执行该文件,返回相应取值:

[root@www bbs]# /usr/local/php/bin/php op_mem.php 
oldboy book

总结

上一篇:ini_set的用法介绍

栏    目:PHP代码

下一篇:php的urlencode()URL编码函数浅析

本文标题:PHP安装memcache扩展的步骤讲解

本文地址:http://www.codeinn.net/misctech/60116.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有