zoukankan      html  css  js  c++  java
  • 阿里云主机安装memcache扩展

     php扩展memcache的作用是为了支持memcached数据库缓存服务器,下面是安装方法。
    1、下载并解压memcache文件

    [plain] view plaincopy
     
    1. wget -c http://pecl.php.net/get/memcache-3.0.6.tgz  
    2. tar xzvf memcache-3.0.6.tgz  
    3. cd memcache-3.0.6  

    2、执行phpize扩展安装程序,假设phpzie的路径为/usr/local/php/bin/phpize,具体的路径得根据自己的环境修改。

    [plain] view plaincopy
     
    1. /alidata/server/php-5.2.17/bin/phpize

    3、开始安装扩展memcache

    [plain] view plaincopy
     
    1.  ./configure --enable-memcache --with-php-config=/alidata/server/php-5.2.17/bin/php-config --with-zlib-dir  
    2. make && make install  

    安装完成后,提示

    [plain] view plaincopy
     
    1. Installing shared extensions:     /alidata/server/php/lib/php/extensions/no-debug-zts-20060613/ 

    4、最后修改php.ini文件,在zend之前(这个似乎是必须的,不能放到最后)加入如下代码。

    [plain] view plaincopy
     
    1. [memcache]  
    2. extension_dir = "/alidata/server/php/lib/php/extensions/no-debug-zts-20060613/"  
    3. extension=memcache.so  

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

    附php的memcache测试代码:

    [php] view plaincopy
     
    1. <?php  
    2. $memcache = new Memcache;  
    3. $memcache->connect('127.0.0.1', 11211) or die ("Could not connect");  
    4. $version = $memcache->getVersion();  
    5. echo "Server's version: ".$version."\n";  
    6. $tmp_object = new stdClass;  
    7. $tmp_object->str_attr = 'test';  
    8. $tmp_object->int_attr = 123;  
    9. $memcache->set('key'$tmp_object, false, 10) or die ("Failed to save data at the server");  
    10. echo "Store data in the cache (data will expire in 10 seconds)\n";  
    11. $get_result = $memcache->get('key');  
    12. echo "Data from the cache:\n";  
    13. var_dump($get_result);  
    14. ?>  
  • 相关阅读:
    Android 摇一摇之双甩功能
    Android 上千张图片的列表滑动加载
    Android 新手引导
    Android 自定义列表指示器
    Mininet的安装与卸载
    ubuntu装机必备
    linux系统中利用vagrant创建虚拟开发环境
    Ubuntu右键添加:open in terminal
    ryu启动问题总结
    新建WORD文档打开会出现转换文件对话框3步解决办法
  • 原文地址:https://www.cnblogs.com/showker/p/3115196.html
Copyright © 2011-2022 走看看