memcache 緩存服務器

部署

主机
操作系统
主机名 /IP 地址
主要软件及版本
服务器@1
Centos7
node11
192.168.11.11
libevent-2.1.8-stable.tar.gz
memcached-1.5.7.tar.gz
客户端@2
Centos7
node12
192.168.11.12
httpd-2.4.25.tar.gz
php-5.5.38.tar.gz
memcache-2.2.7.tgz
web服務器@3Centos7

node13

192.168.11.13

httpd

@1安裝memcached

这里需要安装三个包libevent-2.1.8-stable.tar.gz / memcached-1.5.7.tar.gz / memcached-1.2.8-repcached-2.2.tar.gz

[root@node11 ~]# yum -y install gcc gcc-c++
[root@node11 ~]#tar xf libevent-2.1.8-stable.tar.gz -C /opt/
[root@node11 ~]#cd /opt/libevent-2.1.8-stable/
[root@node11 ~]#./configure --prefix=/usr/local/libevent

....过程略
[root@node11 ~]#make && make install

....过程略
[root@node11 ~]# cd
[root@node11 ~]#tar xf memcached-1.5.7.tar.gz -C /opt/
[root@node11 ~]# cd /opt/memcached-1.5.7/
[root@node11 memcached-1.5.7]# ./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for icc in use... no
checking for clang in use... no
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking whether __SUNPRO_C is declared... no
checking for gcc option to accept ISO C99... -std=gnu99
checking sasl/sasl.h usability... no
checking sasl/sasl.h presence... no
checking for sasl/sasl.h... no
checking for gcov... /usr/bin/gcov
checking for main in -lgcov... yes
checking for library containing clock_gettime... none required
checking for library containing socket... none required
checking for library containing gethostbyname... none required
checking for libevent directory... /usr/local/libevent
checking for library containing umem_cache_create... no
checking for library containing gethugepagesizes... no
checking for stdbool.h that conforms to C99... yes
checking for _Bool... yes
checking for inttypes.h... (cached) yes
checking for sasl_callback_ft... no
checking for print macros for integers (C99 section 7.8.1)... yes
checking for an ANSI C-conforming const... yes
checking for socklen_t... yes
checking for endianness... little
checking for htonll... no
checking for library containing pthread_create... none required
checking for mlockall... yes
checking for getpagesizes... no
checking for memcntl... no
checking for sigignore... yes
checking for clock_gettime... yes
checking for accept4... yes
checking for getopt_long... yes
checking for alignment... none
checking for GCC atomics... yes
checking for GCC 64bit atomics... yes
checking for setppriv... no
checking for pledge... no
checking umem.h usability... no
checking umem.h presence... no
checking for umem.h... no
checking for xml2rfc... no
checking for xsltproc... no
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating doc/Makefile
config.status: creating config.h
config.status: config.h is unchanged
config.status: executing depfiles commands


[root@node11 memcached-1.5.7]# echo $?
0


[root@node11 memcached-1.5.7]# make && make install
make  all-recursive
make[1]: 进入目录“/opt/memcached-1.5.7”
Making all in doc
make[2]: 进入目录“/opt/memcached-1.5.7/doc”
make  all-am
make[3]: 进入目录“/opt/memcached-1.5.7/doc”
make[3]: 对“all-am”无需做任何事。
make[3]: 离开目录“/opt/memcached-1.5.7/doc”
make[2]: 离开目录“/opt/memcached-1.5.7/doc”
make[2]: 进入目录“/opt/memcached-1.5.7”
make[2]: 离开目录“/opt/memcached-1.5.7”
make[1]: 离开目录“/opt/memcached-1.5.7”
make  install-recursive
make[1]: 进入目录“/opt/memcached-1.5.7”
Making install in doc
make[2]: 进入目录“/opt/memcached-1.5.7/doc”
make  install-am
make[3]: 进入目录“/opt/memcached-1.5.7/doc”
make[4]: 进入目录“/opt/memcached-1.5.7/doc”
make[4]: 对“install-exec-am”无需做任何事。
 /usr/bin/mkdir -p '/usr/local/memcached/share/man/man1'
 /usr/bin/install -c -m 644 memcached.1 '/usr/local/memcached/share/man/man1'
make[4]: 离开目录“/opt/memcached-1.5.7/doc”
make[3]: 离开目录“/opt/memcached-1.5.7/doc”
make[2]: 离开目录“/opt/memcached-1.5.7/doc”
make[2]: 进入目录“/opt/memcached-1.5.7”
make[3]: 进入目录“/opt/memcached-1.5.7”
 /usr/bin/mkdir -p '/usr/local/memcached/bin'
  /usr/bin/install -c memcached '/usr/local/memcached/bin'
 /usr/bin/mkdir -p '/usr/local/memcached/include/memcached'
 /usr/bin/install -c -m 644 protocol_binary.h '/usr/local/memcached/include/memcached'
make[3]: 离开目录“/opt/memcached-1.5.7”
make[2]: 离开目录“/opt/memcached-1.5.7”
make[1]: 离开目录“/opt/memcached-1.5.7”


[root@node11 memcached-1.5.7]# echo $?
0


[root@node11 memcached-1.5.7]# ln -s /usr/local/memcached/bin/* /usr/local/bin/


[root@node11 memcached-1.5.7]# memcached -d -m 32m -p 11211 -u root


[root@node11 memcached-1.5.7]# ss -ntl
State      Recv-Q Send-Q Local Address:Port               Peer Address:Port              
LISTEN     0      128            *:11211                      *:*                  
LISTEN     0      128            *:22                         *:*                  
LISTEN     0      100    127.0.0.1:25                         *:*                  
LISTEN     0      128           :::11211                     :::*                  
LISTEN     0      128           :::22                        :::*                  
LISTEN     0      100          ::1:25                    

@2编译安装apache客户机需要的包

@2编译依赖的环境

[root@node12 ~]# yum -y install apr* pkgconfig pcre-devel zlib-devel gcc gcc-c++ lrzsz
已加载插件:fastestmirror, langpacks
local                                                        | 3.6 kB  00:00:00     
Loading mirror speeds from cached hostfile
软件包 1:pkgconfig-0.27.1-4.el7.x86_64 已安装并且是最新版本
软件包 pcre-devel-8.32-15.el7_2.1.x86_64 已安装并且是最新版本
软件包 zlib-devel-1.2.7-17.el7.x86_64 已安装并且是最新版本
软件包 gcc-4.8.5-11.el7.x86_64 已安装并且是最新版本
软件包 gcc-c++-4.8.5-11.el7.x86_64 已安装并且是最新版本
软件包 lrzsz-0.12.20-36.el7.x86_64 已安装并且是最新版本
正在解决依赖关系
--> 正在检查事务
---> 软件包 apr.x86_64.0.1.4.8-3.el7 将被 安装
---> 软件包 apr-devel.x86_64.0.1.4.8-3.el7 将被 安装
---> 软件包 apr-util.x86_64.0.1.5.2-6.el7 将被 安装
---> 软件包 apr-util-devel.x86_64.0.1.5.2-6.el7 将被 安装
--> 正在处理依赖关系 openldap-devel(x86-64),它被软件包 apr-util-devel-1.5.2-6.el7.x86_64 需要
--> 正在处理依赖关系 libdb-devel(x86-64),它被软件包 apr-util-devel-1.5.2-6.el7.x86_64 需要
--> 正在处理依赖关系 expat-devel(x86-64),它被软件包 apr-util-devel-1.5.2-6.el7.x86_64 需要
--> 正在检查事务
---> 软件包 expat-devel.x86_64.0.2.1.0-8.el7 将被 安装
---> 软件包 libdb-devel.x86_64.0.5.3.21-19.el7 将被 安装
---> 软件包 openldap-devel.x86_64.0.2.4.40-13.el7 将被 安装
--> 正在处理依赖关系 cyrus-sasl-devel(x86-64),它被软件包 openldap-devel-2.4.40-13.el7.x86_64 需要
--> 正在检查事务
---> 软件包 cyrus-sasl-devel.x86_64.0.2.1.26-20.el7_2 将被 安装
--> 正在处理依赖关系 cyrus-sasl(x86-64) = 2.1.26-20.el7_2,它被软件包 cyrus-sasl-devel-2.1.26-20.el7_2.x86_64 需要
--> 正在检查事务
---> 软件包 cyrus-sasl.x86_64.0.2.1.26-20.el7_2 将被 安装
--> 解决依赖关系完成

依赖关系解决

====================================================================================
 Package                 架构          版本                      源            大小
====================================================================================
正在安装:
 apr                     x86_64        1.4.8-3.el7               local        103 k
 apr-devel               x86_64        1.4.8-3.el7               local        188 k
 apr-util                x86_64        1.5.2-6.el7               local         92 k
 apr-util-devel          x86_64        1.5.2-6.el7               local         76 k
为依赖而安装:
 cyrus-sasl              x86_64        2.1.26-20.el7_2           local         88 k
 cyrus-sasl-devel        x86_64        2.1.26-20.el7_2           local        310 k
 expat-devel             x86_64        2.1.0-8.el7               local         56 k
 libdb-devel             x86_64        5.3.21-19.el7             local         38 k
 openldap-devel          x86_64        2.4.40-13.el7             local        800 k

事务概要
====================================================================================
安装  4 软件包 (+5 依赖软件包)

总下载量:1.7 M
安装大小:6.5 M
Downloading packages:
------------------------------------------------------------------------------------
总计                                                   8.7 MB/s | 1.7 MB  00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : apr-1.4.8-3.el7.x86_64                                          1/9 
  正在安装    : apr-devel-1.4.8-3.el7.x86_64                                    2/9 
  正在安装    : apr-util-1.5.2-6.el7.x86_64                                     3/9 
  正在安装    : libdb-devel-5.3.21-19.el7.x86_64                                4/9 
  正在安装    : expat-devel-2.1.0-8.el7.x86_64                                  5/9 
  正在安装    : cyrus-sasl-2.1.26-20.el7_2.x86_64                               6/9 
  正在安装    : cyrus-sasl-devel-2.1.26-20.el7_2.x86_64                         7/9 
  正在安装    : openldap-devel-2.4.40-13.el7.x86_64                             8/9 
  正在安装    : apr-util-devel-1.5.2-6.el7.x86_64                               9/9 
  验证中      : cyrus-sasl-2.1.26-20.el7_2.x86_64                               1/9 
  验证中      : apr-1.4.8-3.el7.x86_64                                          2/9 
  验证中      : apr-util-devel-1.5.2-6.el7.x86_64                               3/9 
  验证中      : openldap-devel-2.4.40-13.el7.x86_64                             4/9 
  验证中      : apr-devel-1.4.8-3.el7.x86_64                                    5/9 
  验证中      : apr-util-1.5.2-6.el7.x86_64                                     6/9 
  验证中      : expat-devel-2.1.0-8.el7.x86_64                                  7/9 
  验证中      : libdb-devel-5.3.21-19.el7.x86_64                                8/9 
  验证中      : cyrus-sasl-devel-2.1.26-20.el7_2.x86_64                         9/9 

已安装:
  apr.x86_64 0:1.4.8-3.el7              apr-devel.x86_64 0:1.4.8-3.el7             
  apr-util.x86_64 0:1.5.2-6.el7         apr-util-devel.x86_64 0:1.5.2-6.el7        

作为依赖被安装:
  cyrus-sasl.x86_64 0:2.1.26-20.el7_2    cyrus-sasl-devel.x86_64 0:2.1.26-20.el7_2 
  expat-devel.x86_64 0:2.1.0-8.el7       libdb-devel.x86_64 0:5.3.21-19.el7        
  openldap-devel.x86_64 0:2.4.40-13.el7 

完毕!

编译httpd

[root@node12 ~]# echo $?
0
[root@node12 ~]# tar zxf httpd-2.4.25.tar.gz -C /usr/src
[root@node12 ~]# cd /usr/src/httpd-2.4.25/
[root@node12 ~]#./configure --prefix=/usr/local/httpd --enable-so -- enable-rewrite --enable-charset-lite --enable-cgi 

...过程略。。。 
[root@node12 ~]#make && make install

...过程略...
[root@node12 httpd-2.4.25]# echo $?
0
[root@node12 httpd-2.4.25]# ln -s /usr/local/httpd/bin/* /usr/local/bin
[root@node12 httpd-2.4.25]# sed -i.bak 's/#ServerName/ServerName/g' /usr/local/httpd/conf/httpd.conf
[root@node12 httpd-2.4.25]# echo "/usr/local/httpd/bin/apachectl start" >> /etc/rc.d/rc.local
[root@node12 httpd-2.4.25]# chmod +x /etc/rc.d/rc.local

@2编译安装php

[root@node12 httpd-2.4.25]# cd
[root@node12 ~]# yum -y install zlib-devel libxml2-devel xz-devel autoconf
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
软件包 zlib-devel-1.2.7-17.el7.x86_64 已安装并且是最新版本
正在解决依赖关系
--> 正在检查事务
---> 软件包 autoconf.noarch.0.2.69-11.el7 将被 安装
--> 正在处理依赖关系 m4 >= 1.4.14,它被软件包 autoconf-2.69-11.el7.noarch 需要
--> 正在处理依赖关系 perl(Data::Dumper),它被软件包 autoconf-2.69-11.el7.noarch 需要
---> 软件包 libxml2-devel.x86_64.0.2.9.1-6.el7_2.3 将被 安装
---> 软件包 xz-devel.x86_64.0.5.2.2-1.el7 将被 安装
--> 正在检查事务
---> 软件包 m4.x86_64.0.1.4.16-10.el7 将被 安装
---> 软件包 perl-Data-Dumper.x86_64.0.2.145-3.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

====================================================================================
 Package                 架构          版本                      源            大小
====================================================================================
正在安装:
 autoconf                noarch        2.69-11.el7               local        701 k
 libxml2-devel           x86_64        2.9.1-6.el7_2.3           local        1.0 M
 xz-devel                x86_64        5.2.2-1.el7               local         46 k
为依赖而安装:
 m4                      x86_64        1.4.16-10.el7             local        256 k
 perl-Data-Dumper        x86_64        2.145-3.el7               local         47 k

事务概要
====================================================================================
安装  3 软件包 (+2 依赖软件包)

总下载量:2.1 M
安装大小:12 M
Downloading packages:
------------------------------------------------------------------------------------
总计                                                    13 MB/s | 2.1 MB  00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : xz-devel-5.2.2-1.el7.x86_64                                     1/5 
  正在安装    : m4-1.4.16-10.el7.x86_64                                         2/5 
  正在安装    : perl-Data-Dumper-2.145-3.el7.x86_64                             3/5 
  正在安装    : autoconf-2.69-11.el7.noarch                                     4/5 
  正在安装    : libxml2-devel-2.9.1-6.el7_2.3.x86_64                            5/5 
  验证中      : perl-Data-Dumper-2.145-3.el7.x86_64                             1/5 
  验证中      : m4-1.4.16-10.el7.x86_64                                         2/5 
  验证中      : xz-devel-5.2.2-1.el7.x86_64                                     3/5 
  验证中      : libxml2-devel-2.9.1-6.el7_2.3.x86_64                            4/5 
  验证中      : autoconf-2.69-11.el7.noarch                                     5/5 

已安装:
  autoconf.noarch 0:2.69-11.el7        libxml2-devel.x86_64 0:2.9.1-6.el7_2.3       
  xz-devel.x86_64 0:5.2.2-1.el7       

作为依赖被安装:
  m4.x86_64 0:1.4.16-10.el7          perl-Data-Dumper.x86_64 0:2.145-3.el7         

完毕!
[root@node12 ~]# yum -y localinstall *.rpm
已加载插件:fastestmirror, langpacks
正在检查 libmcrypt-2.5.8-13.el7.x86_64.rpm: libmcrypt-2.5.8-13.el7.x86_64
libmcrypt-2.5.8-13.el7.x86_64.rpm 将被安装
正在检查 libmcrypt-devel-2.5.8-13.el7.x86_64.rpm: libmcrypt-devel-2.5.8-13.el7.x86_64
libmcrypt-devel-2.5.8-13.el7.x86_64.rpm 将被安装
正在检查 mcrypt-2.6.8-11.el7.x86_64.rpm: mcrypt-2.6.8-11.el7.x86_64
mcrypt-2.6.8-11.el7.x86_64.rpm 将被安装
正在检查 mhash-0.9.9.9-10.el7.x86_64.rpm: mhash-0.9.9.9-10.el7.x86_64
mhash-0.9.9.9-10.el7.x86_64.rpm 将被安装
正在解决依赖关系
--> 正在检查事务
---> 软件包 libmcrypt.x86_64.0.2.5.8-13.el7 将被 安装
---> 软件包 libmcrypt-devel.x86_64.0.2.5.8-13.el7 将被 安装
---> 软件包 mcrypt.x86_64.0.2.6.8-11.el7 将被 安装
---> 软件包 mhash.x86_64.0.0.9.9.9-10.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

====================================================================================
 Package         架构   版本             源                                    大小
====================================================================================
正在安装:
 libmcrypt       x86_64 2.5.8-13.el7     /libmcrypt-2.5.8-13.el7.x86_64       283 k
 libmcrypt-devel x86_64 2.5.8-13.el7     /libmcrypt-devel-2.5.8-13.el7.x86_64  19 k
 mcrypt          x86_64 2.6.8-11.el7     /mcrypt-2.6.8-11.el7.x86_64          223 k
 mhash           x86_64 0.9.9.9-10.el7   /mhash-0.9.9.9-10.el7.x86_64         210 k

事务概要
====================================================================================
安装  4 软件包

总计:735 k
安装大小:735 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : libmcrypt-2.5.8-13.el7.x86_64                                   1/4 
  正在安装    : mhash-0.9.9.9-10.el7.x86_64                                     2/4 
  正在安装    : mcrypt-2.6.8-11.el7.x86_64                                      3/4 
  正在安装    : libmcrypt-devel-2.5.8-13.el7.x86_64                             4/4 
  验证中      : libmcrypt-devel-2.5.8-13.el7.x86_64                             1/4 
  验证中      : libmcrypt-2.5.8-13.el7.x86_64                                   2/4 
  验证中      : mhash-0.9.9.9-10.el7.x86_64                                     3/4 
  验证中      : mcrypt-2.6.8-11.el7.x86_64                                      4/4 

已安装:
  libmcrypt.x86_64 0:2.5.8-13.el7       libmcrypt-devel.x86_64 0:2.5.8-13.el7      
  mcrypt.x86_64 0:2.6.8-11.el7          mhash.x86_64 0:0.9.9.9-10.el7              

完毕!
[root@node12 ~]# tar zxf php-5.5.38.tar.gz -C /usr/src
[root@node12 ~]# cd /usr/src/php-5.5.38

 

[root@node12 php-5.5.38]#./configure --prefix=/usr/local/php5 --with-mcrypt -- with-apxs2=/usr/local/httpd/bin/apxs --with-config- file-path=/usr/local/php5 --enable-mbstring 

...过程略。。
[root@node12 php-5.5.38]#make -j 2 && make install

...过程略。。
[root@node12 php-5.5.38]# cp /usr/src/php-5.5.38/php.ini-development /usr/local/php5/php.ini
[root@node12 php-5.5.38]# cd
[root@node12 ~]# tar zxf zend-loader-php5.5-linux-x86_64_update1.tar.gz -C /usr/src/[root@node12 ~]# cd /usr/src/zend-loader-php5.5-linux-x86_64/
[root@node12 zend-loader-php5.5-linux-x86_64]# cp ZendGuardLoader.so /usr/local/php5/lib/php/
[root@node12 zend-loader-php5.5-linux-x86_64]# vim /usr/local/php5/php.ini
default_charset = "UTF-8" #行680附近取消注释
#行340下添加
zend_extension=/usr/local/php5/lib/php/ZendGuardLoader. so 
zend_loader.enable=1
[root@node12 zend-loader-php5.5-linux-x86_64]# 

@2开启服务

[root@node12 zend-loader-php5.5-linux-x86_64]# vim /usr/local/httpd/conf/httpd.conf
[root@node12 zend-loader-php5.5-linux-x86_64]# httpd -t
Syntax OK
[root@node12 zend-loader-php5.5-linux-x86_64]# apachectl restart

@2 浏览器访问@2IP,

[root@node12 ~]# vim /usr/local/httpd/htdosc/test1.php
<?php 
phpinfo(); 
?>

验证LAMP连通性,访问测试  http://192.168.11.11/test1.php

[root@node12 memcache-2.2.7]# vim /usr/local/httpd/htdocs/test1.php
<?php 
$memcache = new Memcache(); 
$memcache->connect('192.168.11.11',11211); 
$memcache->set('key','Memcache test Successfull!',0,60); 
$result = $memcache->get('key'); 
unset($memcache); 
echo $result;
phpinfo(); 
?>
[root@node12 memcache-2.2.7]# 

今天就到这里了,有什么意见

或建议,欢迎提出,大家

一起进步呀!

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值