• 安装memcached服务器和PHP中添加memcache拓展模块


    Memcached是一个高性能的分布式内存对象缓存系统,用于动态web应用以减轻数据库的负载。它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提拱动态 数据驱动网站的速度。

    memcached是其于libevent做事件触发的,首先装libevent.

    wget http://cloud.github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
    
    [root@14LN src]# tar -xzvf libevent-2.0.21-stable.tar.gz 
    [root@14LN libevent-2.0.21-stable]# pwd
    /usr/local/src/libevent-2.0.21-stable
    [root@14LN libevent-2.0.21-stable]# ./configure --prefix=/usr/local/libevent
    [root@14LN libevent-2.0.21-stable]# make && make install
    
    [root@14LN libevent-2.0.21-stable]# ls -al /app/server/libevent/lib/ |grep libevent
    lrwxrwxrwx. 1 root root      21 Jul 12 20:36 libevent-2.0.so.5 -> libevent-2.0.so.5.1.9
    -rwxr-xr-x. 1 root root  968450 Jul 12 20:36 libevent-2.0.so.5.1.9
    -rw-r--r--. 1 root root 1571290 Jul 12 20:36 libevent.a
    lrwxrwxrwx. 1 root root      26 Jul 12 20:36 libevent_core-2.0.so.5 -> libevent_core-2.0.so.5.1.9
    -rwxr-xr-x. 1 root root  585065 Jul 12 20:36 libevent_core-2.0.so.5.1.9
    -rw-r--r--. 1 root root  978042 Jul 12 20:36 libevent_core.a
    -rwxr-xr-x. 1 root root     986 Jul 12 20:36 libevent_core.la
    lrwxrwxrwx. 1 root root      26 Jul 12 20:36 libevent_core.so -> libevent_core-2.0.so.5.1.9
    lrwxrwxrwx. 1 root root      27 Jul 12 20:36 libevent_extra-2.0.so.5 -> libevent_extra-2.0.so.5.1.9
    -rwxr-xr-x. 1 root root  404772 Jul 12 20:36 libevent_extra-2.0.so.5.1.9
    -rw-r--r--. 1 root root  593320 Jul 12 20:36 libevent_extra.a
    -rwxr-xr-x. 1 root root     993 Jul 12 20:36 libevent_extra.la
    lrwxrwxrwx. 1 root root      27 Jul 12 20:36 libevent_extra.so -> libevent_extra-2.0.so.5.1.9
    -rwxr-xr-x. 1 root root     951 Jul 12 20:36 libevent.la
    lrwxrwxrwx. 1 root root      30 Jul 12 20:36 libevent_pthreads-2.0.so.5 -> libevent_pthreads-2.0.so.5.1.9
    -rwxr-xr-x. 1 root root   18470 Jul 12 20:36 libevent_pthreads-2.0.so.5.1.9
    -rw-r--r--. 1 root root   18710 Jul 12 20:36 libevent_pthreads.a
    -rwxr-xr-x. 1 root root    1014 Jul 12 20:36 libevent_pthreads.la
    lrwxrwxrwx. 1 root root      30 Jul 12 20:36 libevent_pthreads.so -> libevent_pthreads-2.0.so.5.1.9
    lrwxrwxrwx. 1 root root      21 Jul 12 20:36 libevent.so -> libevent-2.0.so.5.1.9
    [root@14LN libevent-2.0.21-stable]# 
    

    接下来安装Memcached:

    [root@14LN src]# wget http://pkgs.fedoraproject.org/lookaside/pkgs/memcached/memcached-1.4.15.tar.gz/36ea966f5a29655be1746bf4949f7f69/memcached-1.4.15.tar.gz
    
    [root@14LN src]# tar -xzvf memcached-1.4.15.tar.gz 
    [root@14LN src]# cd memcached-1.4.15
    [root@14LN memcached-1.4.15]# ./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent
    [root@14LN memcached-1.4.15]# make && make install
    安装php扩展模块memcache
    [root@14LN src]# wget http://pecl.php.net/get/memcache-2.2.6.tgz
    [root@14LN src]# cd memcache-2.2.6
    [root@14LN memcache-2.2.6]# /usr/local/php/bin/phpize 
    Configuring for:
    PHP Api Version:         20121113
    Zend Module Api No:      20121212
    Zend Extension Api No:   220121212
    [root@14LN memcache-2.2.6]# ./configure --enable-memcache --with-php-config=/usr/local/php/bin/php-config --with-zlib-dir
    [root@14LN memcache-2.2.6]# make && make install
    
    
    
    
    安装成功会有类似下面的提示:
    Build complete.
    Don't forget to run 'make test'.
    
    Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/
    
    [root@14LN memcache-2.2.6]# egrep 'memcache|extension_dir' /etc/php.ini
    [memcache]
    extension_dir="/usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/"
    extension=memcache.so
    ; extension_dir = "./"
    ; extension_dir = "ext"
    ; Be sure to appropriately set the extension_dir directive.
    ;sqlite3.extension_dir =
    
    启动memcache
    [root@14LN memcache-2.2.6]# /usr/local/memcached/bin/memcached -d -u root -m 63 -p 11211 -c 10240
    
    [root@14LN memcache-2.2.6]# service php-fpm restart
    Gracefully shutting down php-fpm . done
    Starting php-fpm  done
    

     

  • 相关阅读:
    SQL注入: with rollup特性
    【转】kali配置--修改IP和DNS
    【转】getopt模块,实现获取命令行参数
    socket编程: TypeError: must be bytes or buffer, not str
    Ansible进阶之企业级应用
    Ansible之Playbook详解
    Ansible之常用模块介绍
    JAVA企业级应用Tomcat实战
    ubuntu网络、包管理、工作内容小结
    shell细节决定高度
  • 原文地址:https://www.cnblogs.com/bass6/p/5615195.html
Copyright © 2020-2023  润新知