• Centos5.3下安装memcached


    Memcached启动关闭命令

    memcached启动参数描述:

    -d :启动一个守护进程,

    -m:分配给Memcache使用的内存数量,单位是MB,默认是64MB,

    -u :运行Memcache的用户

    -l  :监听的服务器IP地址

    -p :设置Memcache监听的端口,默认是11211    注:-p(p为小写)

    -c :设置最大并发连接数,默认是1024

    -P :设置保存Memcache的pid文件   注:-P(P为大写)

    由于memcached采用libevent事件,在安装memcached之前,首先确认系统是否安装了libevent

    [root@localhost /]# ll /usr/lib | grep libevent
    lrwxrwxrwx   1 root root       22 05-10 11:25 libevent-1.1a.so.1 -> libevent-1.1a.so.1.0.2
    -rwxr-xr-x   1 root root    31596 2007-01-07 libevent-1.1a.so.1.0.2

    如果没有安装首选需要安装libevent

    [root@localhost src]# wget https://github.com/downloads/libevent/libevent/libevent-2.0.20-stable.tar.gz
    解压后,进行安装
    [root@localhost libevent-2.0.20-stable]#./configure --prefix=/usr/local/libevent/
    [root@localhost libevent-2.0.20-stable]# make
    [root@localhost libevent-2.0.20-stable]# make install
     

    Memcached 安装

    1.到http://memcached.org/上下载memcache,现在最新版本memcached-1.4.15.tar.gz

    2.解压

    [root@localhost src]# tar -zxvf memcached-1.4.15.tar.gz 

    3.

    [root@localhost memcached-1.4.15]# ./configure --prefix=/usr/local/memcached/ --with-libevent=/usr/local/libevent/
    [root@localhost memcached-1.4.15]# make

    [root@localhost memcached-1.4.15]# makeinstall
     

    4.启动memcached

    [root@localhost memcached-1.4.15]# /usr/local/memcached/bin/memcached -d -u root

    [root@localhost memcached-1.4.15]# ps aux | grep memcached
    root      5310  0.0  0.6  55504  1720 ?        Ssl  22:01   0:00 /usr/local/memcached/bin/memcached -d -u root
    root      9495  0.0  0.2   5108   700 pts/2    S+   22:59   0:00 grep memcached

    5.将memcached作为php的扩展

    [root@localhost src]# tar -zxvf memcache-2.2.5.tgz
    [root@localhost src]# cd memcache-2.2.5
    [root@localhost memcache-2.2.5]# /usr/local/php/bin/phpize
    [root@localhost memcache-2.2.5]# ./configure --with-php-config=/usr/local/php/bin/php-config
    [root@localhost memcache-2.2.5]# make
    [root@localhost memcache-2.2.5]# make install

    6.

    6.修改php.ini文件
    打开/usr/local/php/etc/php.ini中的extension_dir = "./"
    修改为extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613"
    并在此行后增加
    extension = "memcache.so"

    7.重新启动nginx后,通过php测试

    $host='127.0.0.1';
    $port=11211;
    $mem=new Memcache();
    $mem->connect($host,$port);
    $mem->set("key","sucess");
    echo $mem->get("key"
  • 相关阅读:
    [译]JavaScript源码转换:非破坏式与再生式
    [译]ES6中的代理对象
    tensorflow 如何获取graph中的所有tensor name
    python3中的str和bytes
    git submodule 添加 更新 删除 教程
    《重构:改善既有代码的设计》摘抄
    thrift入门教程/thrift资料集合
    将python2代码升级为python3代码最佳实践
    python标准库:subprocess——子进程管理
    安装“python-snappy”遇到“error: command 'x86_64-linux-gnu-gcc' failed with exit status 1”
  • 原文地址:https://www.cnblogs.com/daly2008/p/2769744.html
Copyright © 2020-2023  润新知