Apache+php+memcache Cluster Construction

Source: Internet
Author: User
Tags zts zend

Experimental environment: RHEL7.0 server1.example.com 172.25.254.1

Server2.example.com 172.25.254.2

Experimental premise: has been compiled and installed to complete PHP and Nginx, the specific content can refer to the front of the blog content:.

Experimental content: 1.memcache installation

2. Compile and install memcache so that it supports PHP

3. Modify the PHP configuration file and configure the Memcache test page

4. Testing

installation package: Memcache-2.2.5.tgz  


1.memcache installation (the port number of the memcache is 11211)

[email protected] ~]# Yum install memcached-y

[[email protected] ~]#/etc/init.d/httpd start

[[email protected] ~]#/etc/init.d/memcached start

[Email protected] ~]# curl-i localhost

http/1.1 OK

Date:sun, Sep 16:31:52 GMT

server:apache/2.2.15 (Red Hat)

Last-modified:sun, Sep 16:15:02 GMT

ETag: "1FCA9-8-53C3DAE8AE0CF"

Accept-ranges:bytes

Content-length:8

Connection:close

content-type:text/html; Charset=utf-8

[[Email protected] ~]# telnet 127.0.0.1 11211

Trying 127.0.0.1 ...

Connected to 127.0.0.1.

Escape character is ' ^] '.

Stats

STAT PID 2759

STAT Uptime 14

STAT Time 1473611553

STAT version 1.4.4

........................

STAT Total_items 0

STAT Evictions 0

END


2. Compile and install memcache so that it supports PHP

[[email protected] mnt]# php-m |grep memcache # # # can see PHP does not support memcached

[Email protected] ~]# cd/mnt/

[[email protected] mnt]# ls

Memcache-2.2.5.tgz

[Email protected] mnt]# tar-zxf memcache-2.2.5.tgz # # #解压 tar zxf memcache-2.2.5.tgz

[Email protected] mnt]# CD memcache-2.2.5 # # #进入解压目录

[[email protected] memcache-2.2.5]# ls

[Email protected] memcache-2.2.5]# Phpize # #会自动生成configure

Configuring for:

PHP Api version:20131106

Zend Module Api no:20131226

Zend Extension Api no:220131226

[email protected] memcache-2.2.5]# Yum install libtool-y

[Email protected] memcache-2.2.5]#/configure \

>--prefix=/usr/local/lnmp/php/modules \

>--enable-memcache

[email protected] memcache-2.2.5]# make # #编译

[[email protected] memcache-2.2.5]# make install # # #安装

Installing Shared extensions:/usr/local/lnmp/php/lib/php/extensions/no-debug-non-zts-20131226/

[Email protected] memcache-2.2.5]# cd/usr/local/lnmp/php/lib/php/extensions/no-debug-non-zts-20131226/

[[email protected] no-debug-non-zts-20131226]# ls

memcache.so Opcache.a opcache.so

[Email protected] no-debug-non-zts-20131226]#/etc/init.d/memcached restart


3. Compile the PHP configuration file and configure the Memcache test page

[Email protected] ~]# Vim/usr/local/lnmp/php/etc/php.ini

863 extension=memcache.so

[Email protected] ~]#/etc/init.d/fpm restart

[Email protected] ~]# php-m |grep Mem # # #查看php是否支持memcached

Memcache

[Email protected] ~]# cd/mnt/memcache-2.2.5

[email protected] memcache-2.2.5]# CP example.php memcache.php/usr/local/lnmp/nginx/html/

[Email protected] memcache-2.2.5]# cd/usr/local/lnmp/nginx/html/

[Email protected] html]# Vim example.php # #分析信息不做修改

Define (' Admin_username ', ' memcache '); Admin Username

Define (' Admin_password ', ' Willis '); Admin Password # #willis为密码


$MEMCACHE _servers[] = ' 127.0.0.1:11211 '; Add more as an array

# $MEMCACHE _servers[] = ' mymemcache-server2:11211 '; Add more as an array

[Email protected] html]# Nginx-s Reload


4. Testing

http://172.25.6.10/example.php# #访问网站并多次刷新

http://172.25.6.10/memcache.php# #查看命中率

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/87/5B/wKiom1feHw_T1_49AABJ6N0Rd3k727.png "style=" width : 700px;height:79px; "title=" screenshot from 2016-09-15 23:43:56.png "width=" to "height=" "border=" 0 "hspace=" 0 " Vspace= "0" alt= "wkiom1fehw_t1_49aabj6n0rd3k727.png"/>

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/87/58/wKioL1feHxCxiodGAAA2_iwLyFE937.png "style=" width : 500px;height:189px; "title=" screenshot from 2016-09-15 23:44:39.png "width=", "height=" 189 "border=" 0 "hspace=" 0 " Vspace= "0" alt= "wkiol1fehxcxiodgaaa2_iwlyfe937.png"/>


650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/87/5B/wKiom1feHxGx3krkAAERJFXkOfM028.png "style=" width : 700px;height:422px; "title=" screenshot from 2016-09-15 23:50:03.png "width=" to "height=" 422 "border=" 0 "hspace=" 0 " Vspace= "0" alt= "wkiom1fehxgx3krkaaerjfxkofm028.png"/>

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/87/58/wKioL1feHxGx7X2AAAA3Zv1FvqQ300.png "style=" width : 500px;height:270px; "title=" screenshot from 2016-09-15 23:50:30.png "width=" height= "" border= "0" hspace= "0" Vspace= "0" alt= "wkiol1fehxgx7x2aaaa3zv1fvqq300.png"/>

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/87/58/wKioL1feHxLQLtRAAAC_Ei-MgW4823.png "style=" width : 700px;height:253px; "title=" screenshot from 2016-09-15 23:50:44.png "width=" to "height=" 253 "border=" 0 "hspace=" 0 " Vspace= "0" alt= "wkiol1fehxlqltraaac_ei-mgw4823.png"/>

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/87/5B/wKiom1feHxOyaL-jAAA2uxe4c80661.png "style=" width : 500px;height:269px; "title=" screenshot from 2016-09-15 23:50:49.png "width=", "height=" 269 "border=" 0 "hspace=" 0 " Vspace= "0" alt= "wkiom1fehxoyal-jaaa2uxe4c80661.png"/>


This article from the "Technology life, Simple not simple" blog, please be sure to keep this source http://willis.blog.51cto.com/11907152/1853588

Apache+php+memcache Cluster Construction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.