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. ?>  
  • 相关阅读:
    odoo 的各种domain
    odoo search之时间搜索,时间段查询
    git 修改远程仓库地址
    Windows 挂起进程
    结构体 偏移量 (size_t)&(((s *)0)->m) , list相关
    Data Flow Diagram with Examples
    Windows环境,获取当前线程的ID,GetCurrentThreadId
    获取 保存 系统信息 [Windows]
    notepad正则删除关键词所在行
    文件或文件夹改变后,发信号让系统刷新
  • 原文地址:https://www.cnblogs.com/showker/p/3115196.html
Copyright © 2011-2022 走看看