64位机器上安装memcache


机器ip为192.168.6.210,64位centOS5                
1,首先下载到memcached和libevent
   memcache需要libevent的支持
   #cd /usr/local/src/
   # wget http://www.danga.com/memcached/dist/memcached-1.2.0.tar.gz
   # wget http://www.monkey.org/~provos/libevent-1.2.tar.gz
2,安装libevent
   # tar zxvf libevent-1.2.tar.gz -C /usr/local/
   # cd libevent-1.2
   # ./configure --prefix=/usr/local
   # make
   # make install
   查看是否安装成功,进行确认:
   # ls -al /usr/local/lib | grep libevent
   在210上出现如下信息,安装成功:
   lrwxrwxrwx   1 root root     21 Mar 22 18:41 libevent-1.2.so.1 -> libevent-1.2.so.1.0.3
   -rwxr-xr-x   1 root root 262475 Mar 22 18:41 libevent-1.2.so.1.0.3
   -rw-r--r--   1 root root 430228 Mar 22 18:41 libevent.a
   -rwxr-xr-x   1 root root    811 Mar 22 18:41 libevent.la
   lrwxrwxrwx   1 root root     21 Mar 22 18:41 libevent.so -> libevent-1.2.so.1.0.3
3,安装memcached
   安装memcached时,需要指定libevent的安装位置:
   # tar zxvf memcached-1.2.0.tar.gz -C /usr/local
   # cd memcached-1.2.0
   # ./configure --with-libevent=/usr/local
   # make
   # make install
   安装完成后会将memcached放到/usr/local/bin/memcached,查看是否安装成功:
   # ls -al /usr/local/bin/mem*
   出现如下信息:
   -rwxr-xr-x  1 root root 114673 Mar 22 18:52 /usr/local/bin/memcached
   -rwxr-xr-x  1 root root 120092 Mar 22 18:52 /usr/local/bin/memcached-debug
  
   安装完成了,现在我们看一下memcache的帮助:
   # /usr/local/bin/memecached -h
   这时候出现了如下错误:
   memcached: error while loading shared libraries:libevent-1.2.so.1: cannot open shared    object file: No such file ordirectory
   下面说下修复过程:
    # LD_DEBUG=libs memcached -v 查看memcached的libs的路径
    在210上出现了如下信息:
      5427:     find library=libevent-1.2.so.1 [0]; searching
      5427:      search cache=/etc/ld.so.cache
       5427:      search       path=/lib64/tls/x86_64:/lib64/tls:/lib64/x86_64:/lib64:/usr/lib64/tls/x86_64:/usr/lib64/tls:/usr/lib64/x86_64:
/usr/lib64              (system search path)
      5427:       trying file=/lib64/tls/x86_64/libevent-1.2.so.1
      5427:       trying file=/lib64/tls/libevent-1.2.so.1
      5427:       trying file=/lib64/x86_64/libevent-1.2.so.1
      5427:       trying file=/lib64/libevent-1.2.so.1
      5427:       trying file=/usr/lib64/tls/x86_64/libevent-1.2.so.1
      5427:       trying file=/usr/lib64/tls/libevent-1.2.so.1
      5427:       trying file=/usr/lib64/x86_64/libevent-1.2.so.1
      5427:       trying file=/usr/lib64/libevent-1.2.so.1
      5427:
                  memcached: error while loading shared libraries:libevent-1.2.so.1: cannot open shared object file: Nosuch                   file or directory

    现在应该记录下来libs的位置,我选择的是trying file=/usr/lib64/libevent-1.2.so.1
    现在我们利用这个来做个符号链接:
    # ln -s /usr/local/lib/libevent-1.2.so.1 /usr/lib64/libevent-1.2.so.1
    下面我们继续使用memcached -h做下测试,终于出现了如下信息:
    memcached 1.2.0
    -p <num>      port number to listen on
    -s <file>     unix socket path to listen on (disables network support)
    -l <ip_addr>  interface to listen on, default is INDRR_ANY
    -d            run as a daemon
    -r            maximize core file limit
    -u <username> assume identity of <username> (only when run as root)
    -m <num>      max memory to use for items in megabytes, default is 64 MB
    -M            return error on memory exhausted (rather than removing items)
    -c <num>      max simultaneous connections, default is 1024
    -k            lock down all paged memory
    -v            verbose (print errors/warnings while in event loop)
    -vv           very verbose (also print client commands/reponses)
    -h            print this help and exit
    -i            print memcached and libevent license
    -b            run a managed instanced (mnemonic: buckets)
    -P <file>     save PID in <file>, only used with -d option
    -f <factor>   chunk size growth factor, default 1.25
    -n <bytes>    minimum space allocated for key+value+flags, default 48

    说明memcached安装成功。(应该是机器是64位的原因,所以将so文件放到了lib64下面,而不是lib下面,使得memcached找不到了so文件)
    下面,我们来启动一个Memcached的服务器端:
    # /usr/local/bin/memcached -d -m 10  -u root -l 192.168.0.200 -p 12000 -c 256 -P /tmp/memcached.pid

4,安装memcache PHP模块
   # tar vxzf memcache-1.5.tgz -C /usr/local/
   # cd memcache-1.5
   # /usr/local/php/bin/phpize
   # ./configure --enable-memcache --with-php-config=/usr/local/php/bin/php-config --with-zlib-dir
   # make
   # make install
   之后会提示:
   Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20050922/
   把这个记住,然后修改php.ini,把extension_dir = "./"修改为extension_dir ="/usr/local/php/lib/php/extensions/no-debug-non-zts-20050922/",并添加一行extension=memcache.so
  
   然后重起apache,查看phpinfo(),如果有memcache模块,则说明安装成功。

智能推荐

注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
© 2014-2019 ITdaan.com 粤ICP备14056181号  

赞助商广告