Environment: Centos 6.6
PHP version:5.5.38
Memcached version:1.4.33
Official website: https://memcached.org/
Memcached githup: Https://github.com/memcached/memcached/wiki
Install Libevent:
[Email protected] ~]# ntpdate time.windows.com[[email protected] ~]# wget https://cloud.github.com/downloads/libevent /libevent/libevent-2.0.21-stable.tar.gz[[email protected] ~]# tar-zxf Libevent-2.0.21-stable.tar.gz[[email Protected] ~]# CD Libevent-2.0.21-stable[[email protected] libevent-2.0.21-stable]#./configure--prefix=/usr/local/ Libevent[[email protected] libevent-2.0.21-stable]# make && make Install[[email protected] ~]# ls/usr/local/ Libevent/bin include Lib[[email protected] ~]#
Install memcached:
[Email protected] ~]# wget https://memcached.org/files/memcached-1.4.33.tar.gz[[email protected] ~]# TAR-ZXF Memcached-1.4.33.tar.gz[[email protected] ~]# CD Memcached-1.4.33[[email protected] memcached-1.4.33]#./configure-- prefix=/usr/local/memcached--with-libevent=/usr/local/libevent/[[email protected] memcached-1.4.33]# make & & make Install[[email protected] ~]# Ls/usr/local/memcached/bin include share[[email protected] ~]#
To install the PHP extension Module memcache:
[[Email protected] ~]# yum -y install php55w php55w-cli php55w-common php55w-devel php55w-gd php55w-odbc php55w-mysql php55w-fpm nginx[[email protected] ~]# wget http://nchc.dl.sourceforge.net/project/libpng/zlib/1.2.8/zlib-1.2.8.tar.gz[ [email protected] ~]# tar -zxf zlib-1.2.8.tar.gz[[email protected] ~]# cd zlib-1.2.8[[email protected] zlib-1.2.8]# ./configure --prefix=/usr/local/ zlib[[email protected] zlib-1.2.8]# make && make install[[email protected] ~]# wget http://pecl.php.net/get/memcache-2.2.7.tgz[[email protected] ~]# tar -xf memcache-2.2.7.tgz[[email protected] ~]# cd memcache-2.2.7[[email protected] memcache-2.2.7]# phpize // If Phpize is not installed, install Php55w-develconfiguring for:php api version: 20121113zend module api no: 20121212zend extension Api No: 220121212[[email protected] memcache-2.2.7]#[[email protected] memcache-2.2.7]# ./configure --enable-memcache --with-php-config=/usr/bin/ php-config --with-zlib-dir=/usr/local/zlib/[[email protected] memcache-2.2.7]# make && make install installing shared extensions: /usr/lib64/php/modules/[[email Protected] memcache-2.2.7]#[[email protected] memcache-2.2.7]# make test
In the php.ini file, add the following code before Zend:
[Email protected] ~]# Head-352/etc/php.ini | Tail-3[memcache]extension_dir = "/usr/lib64/php/modules/" extension = Memcache.so[[email protected] ~]#
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/8A/58/wKioL1gubRyRUv24AAAjNrlVJqU556.png "title=" 1.png " alt= "Wkiol1gubryruv24aaajnrlvjqu556.png"/>
[Email protected] ~]# Cd/usr/share/nginx/html[[email protected] html]# cat Info.php<?phpphpinfo ()? >[[email Protected] Html]#[[email protected] ~]#/etc/init.d/php-fpm start[[email protected] ~]#/etc/init.d/nginx Start[[email Protected] ~]# chkconfig--add php-fpm[[email protected] ~]# chkconfig--add nginx[[email protected] ~]# chkconfig PHP-FPM On[[email protected] ~]# chkconfig nginx on
Start memcached
[Email protected] ~]#/usr/local/memcached/bin/memcached-d-u root-m 512-p 11211 127.0.0.1-c 10240-p/USR/LOCAL/MEMC Ached/memcached.pid
Specifies the number of startup threads, starting 4 threads by default
启动参数说明:
The-D option is to start a daemon, M is the amount of memory allocated to Memcache, the unit is MB, the default 64mb-m return error on memory exhausted (rather than removing items) -U is the user running memcache, and if it is currently root, you need to specify the user with this parameter. -L is the server IP address of the listener, which defaults to all network cards. -P is the port that sets the TCP listener for memcache, preferably more than 1024 of the port-C option is the maximum number of concurrent connections to run, the default is 1024-p is to set the PID file to save Memcache
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/8A/58/wKioL1gubTPgMQW4AAATmh3C_cM015.png "style=" float: none; "title=" 1.png "alt=" Wkiol1gubtpgmqw4aaatmh3c_cm015.png "/>
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/8A/58/wKioL1gubTODUp7cAAAZT93CvoI266.png "style=" float: none; "title=" 2.png "alt=" Wkiol1gubtodup7caaazt93cvoi266.png "/>
[Email protected] ~]# Php-m | grep memcachememcache[[email protected] ~]#
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/8A/58/wKioL1gubUzhw-MRAAAzjDbMYsA456.png "style=" float: none; "title=" 1.png "alt=" Wkiol1gubuzhw-mraaazjdbmysa456.png "/>
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/8A/5C/wKiom1gubU2yErrtAAAk9dHBXc8665.png "style=" float: none; "title=" 2.png "alt=" Wkiom1gubu2yerrtaaak9dhbxc8665.png "/>
Nginx配置:
[[email protected] ~]# cat /etc/nginx/conf.d/default.confserver { listen 80; server_name 192.168.70.188; charset utf8; access_log /var/ log/nginx/log/host.access.log main; location / { root /usr/share/nginx/html; index index.php index.html index.htm; } location ~ ^ (. +.php) (. *) $ {root /usr/share/nginx/html; fastcgi_split_path_info ^ (. +.php) (. *) $; include fastcgi.conf; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param PATH_INFO $fastcgi _ path_info; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; }}[[email protected] ~]#[[email protected] ~]# cat /etc/nginx/fastcgi.conf fastcgi_ param script_filename $document _root$fastcgi_script_name;fastcgi_param QUERY_STRING $query _string;fastcgi_param request_ method $request _method;fastcgi_param content_type $content_type;fastcgi_param content_length $content _length;fastcgi_param SCRIPT_NAME $fastcgi _script_name;fastcgi_param REQUEST_URI $request _uri;fastcgi_param document_uri $document _uri;fastcgi_param document_root $document _root;fastcgi_param server_protocol $server _protocol;fastcgi_param https $https if_not_empty;fastcgi_param GATEWAY_INTERFACE cgi/1.1;fastcgi_param server_software nginx/$nginx _version;fastcgi_param REMOTE_ADDR $remote _addr;fastcgi_param Remote_port $remote _port;fastcgi_param server_addr $server _addr;fastcgi_param server_port $server _port;fastcgi_param server_name $server _name;# php only, required if php was built with -- enable-force-cgi-redirectfastcgi_param redirect_status 200; [[email protected] ~]#
Success.
This article from "Pengcheng-soy sauce bottle" blog, declined reprint!
memcached Installing and enabling PHP extension support