怎么搭建Memcache服务

  

安装Memcache

Memcache的搭建需要借助于灯或LNMP,本篇博文采用LNMP结构

安装环境如下:
 <代码> 192.168.148.129,Memcache
  192.168.148.130,php
  192.168.148.131,nginx
  192.168.148.136,mysql代码 
    <李>安装nginx李

下载nginx软件包

 <代码> [root@bogon ~] #, useradd - m - s/sbin/nologin nginx
  (root@bogon ~) #,百胜- y openssl-devel安装
  (root@bogon ~) #焦油zxf pcre-8.39.tar。广州- c/usr/src
  (root@bogon ~) #,焦油zxf zlib-1.2.8.tar。广州- c/usr/src
  (root@bogon ~) #,焦油zxf nginx-1.14.0.tar。广州- c/usr/src
  (root@bogon ~) #, cd/usr/src/nginx-1.14.0/[root@bogon, nginx-1.14.0] # ./configure——prefix=/usr/地方/nginx \
  ——用户=nginx——组=nginx with-http_dav_module \
  ——with-http_stub_status_module with-http_addition_module \
  ——with-http_sub_module with-http_flv_module——with-http_mp4_module \
  ——with-pcre=/usr/src/pcre - 8.39——with-zlib=/usr/src/zlib-1.2.8 \
  ——with-http_ssl_module with-http_gzip_static_module,,使,,制作安装
  (root@bogon ~) #, ln - s/usr/local/nginx/sbin/nginx/usr/local/sbin
  (root@bogon ~) # nginx
  (root@bogon ~) #, netstat -anpt | grep 80
  tcp,,,,0,0 0.0.0.0:80大敌;,,,,,,0.0.0.0:*,,,,,,,听,,,8460/nginx:主人, 
    <李>安装PHP服务器

下载PHP软件包

 <代码> [root@localhost ~] # yum - y安装libxml2-devel lzip2-devel libcurl-devel, libmcrypt-devel openssl-devel bzip2-devel
  (root@localhost ~) #焦油zxf libmcrypt-2.5.7.tar.gz
  root@localhost ~ # cd libmcrypt-2.5.7/[root@localhost libmcrypt-2.5.7] # ./configure——prefix=/usr/地方/libmcrypt,,使,,制作安装
  (root@localhost ~) #焦油zxf php-5.6.27.tar.gz
  root@localhost ~ # cd php-5.6.27/[root@localhost php-5.6.27] # ./configure——prefix=/usr/地方/php5.6——使用mysql=mysqlnd \
  ——with-pdo-mysql=mysqlnd with-mysqli=mysqlnd——使用openssl enable-fpm——enable-sockets \
  ——enable-sysvshm enable-mbstring——with-freetype-dir with-jpeg-dir——with-png-dir with-zlib \
  ——with-libxml-dir=/usr启用xml——with-mhash with-mcrypt=/usr/地方/libmcrypt, \
  ——with-config-file-path=/etc with-config-file-scan-dir=/etc/php。d \
  ——with-bz2 enable-maintainer-zts,,使,,制作安装
  [root@localhost php-5.6.27] # cp php。ini-production/etc/php.ini
  [root@localhost php-5.6.27] # cp sapi/fpm摆在。php-fpm/etc/init.d/php-fpm
  [root@localhost php-5.6.27] # chmod + x/etc/init.d/php-fpm
  [root@localhost php-5.6.27] # chkconfig——添加php-fpm
  [root@localhost php-5.6.27] # chkconfig php-fpm alt="怎么搭建Memcache服务"> 

怎么搭建Memcache服务

    <李>安装Memecache李

下载Memcache

 <代码> [root@bogon ~] #焦油zxf libevent-2.0.22-stable.tar。广州- c/usr/src/root@bogon ~ # cd/usr/src/libevent-2.0.22-stable/[root@bogon libevent-2.0.22-stable] # ./configure,,使,,制作安装
  (root@bogon ~) #焦油zxf memcached-1.4.33.tar。广州- c/usr/src/root@bogon ~ # cd/usr/src/memcached-1.4.33/[root@bogon memcached-1.4.33] # ./configure——prefix=/usr/地方/memcached \
  比;——with-libevent=/usr/地方/,,使,,制作安装
  (root@bogon ~) # 2048 - l 192.168.1.7 memcached - d - m - p 11211 - c 10240 - p/usr/local/memcached/memcached.pid - u根
  (root@bogon ~) # netstat -anpt | grep 11211  
    <李> php操作如下(安装Memecache客户端)
 <代码> [root@bogon ~] #焦油zxf memcache-3.0.8。tgz - c/usr/src/root@bogon ~ # cd/usr/src/memcache-3.0.8/[root@bogon memcache-3.0.8] #/usr/local/php5.6/bin/phpize
  [root@PHP memcache-3.0.8] # ./configure——enable-memcache \
  ——with-php-config=/usr/地方/php/bin/php-config,,使,,制作安装//执行后会显示memcache.so存放的路径
  (root@PHP ~) #回声“扩展=/usr/local/php/lib/php/extensions/no -调试- zt型- 20131226/memcache.so"在比;/etc/php.ini//在PHP主配置文件中填写memcache.so模块存放的路径
  (root@PHP ~) # systemctl php-fpm重启
  # vim/var/www/html/test2.php root@PHP ~
  php & lt; ?
  memcache=new memcache美元;
  memcache→美元连接(& # 39;192.168.1.129& # 39;,11211)或死亡(“不能connect");
  version=memcache→美元getVersion ();
  回声“服务器# 39;s版:“。美元版本!”& lt; br/在“;
  $ tmp_object=新stdClass;
  美元tmp_object→str_attr=& # 39;测试# 39;;
  美元tmp_object→int_attr=123;
  美元memcache→设置(& # 39;关键# 39;,tmp_object美元,假的,600)或死亡(“未能在server"保存数据);
  回声,在缓存中存储数据(数据将在600年到期秒)& lt; br/在“;
  get_result=memcache→美元得到(& # 39;关键# 39;);
  回声“数据从缓存中:& lt; br/在“;
  get_result美元var_dump ();
  比;//此测试脚本是显示memcached的版本
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null

怎么搭建Memcache服务