Several Methods for installing Memcached + memcached extension in linux-CentOS6.4 + installing memcache extension + Memcache synchronization SESSION

Source: Internet
Author: User
Tags php memcached zts

I. Prepare the compiling environment. yum install gcc-c ++ libstdc ++-devel yum install zlib-devel 2. Prepare the wget http://monkey.org in the source package /~ Provos/libevent-1.4.14b-stable.tar.gzwget http://memcached.googlecode.com/files/memcached-1.4.15.tar.gz 3. installation and configuration 1. Installation of libevent tar zxvf libevent-1.4.14b-stable.tar.gz cd libevent-1.4.14b-stable. /configure -- prefix =/usr/local/libevent/make & make install ln-s/usr/local/libevent/lib/libevent-1.4.so.2/lib/libevent-1.4.so.2 2. install Memcached tar zxvf memcached-1.4.15.tar.gz cd memcached-1.4.15. /config Ure -- prefix =/usr/local/memcached/-- with-libevent =/usr/local/libevent/make & make install 3. Start Memcached/usr/local/memcached/bin /memcached-d-m 64-u root-l 127.0.0.100-p 11211-c 128-P/tmp/memcached. pid 4. Write a SHELL script for ease of management. # Http://blog.phpha.com # the following content is taken from Internet vi/etc/rc. d/init. d/memcached #! /Bin/sh # memcached: MemCached Daemon # chkconfig:-90 25 # deion: MemCached Daemon # Source function library .. /etc/rc. d/init. d/functions. /etc/sysconfig/network # [$ {NETWORKING} = "no"] & exit 0 # [-r/etc/sysconfig/dund] | exit 0 #. /etc/sysconfig/dund # [-z "$ DUNDARGS"] & exit 0 start () {echo-n $ "Starting memcached: "daemon $ MEMCACHED-u daemon-d-m 64-l 127.0.0.100-p 11211-c 128-P/tmp/memcached. pid echo} stop () {echo-n $ "Shutting down memcached: "killproc memcached echo} MEMCACHED ="/usr/local/memcached/bin/memcached "[-f $ MEMCACHED] | exit 1 # See how we were called. case "$1" in start) start; stop) stop; restart) stop sleep 3 start; *) echo $ "Usage: $0 {start | stop | restart} "exit 1 esac exit 0 5. Add Memcached to boot cd/etc/rc. d/init. d/chmod 777 memcached Chkconfig -- add memcached chkconfig -- level 235 memcached on chkconfig -- list | grep memcached 6. Memcached uses service memcached start service memcached stop service memcached restart 4. PHP installs Memcache extensions (memcache and memcached extensions) select either of them, we recommend that you install the following memcached) [root ~] Wget-c http://pecl.php.net/get/memcache-3.0.8.tgz [root ~] Tar-zxvf memcache-3.0.8.tgz [root ~] Cd memcache-3.0.8 [root ~] /Usr/local/php/bin/phpize [root ~] ./Configure -- with-php-config =/usr/local/php/bin/php-config -- enable-memcache -- with-zlib-dir [root ~] Make & make install/usr/local/php/lib/php/extension/ no-debug-non-zts-20121212/memcache. so [root ~] Vim/usr/local/php/etc/php. ini extension =/usr/local/php/lib/php/extension/ no-debug-non-zts-20121212/memcache. so session. save_handler = memcache session. save_path = "tcp: // 127.0.0.100: 11211" [root ~] How to install memcache extension in service php-fpm reload php5.5 +: because php5.5 + has built-in memcache extensions, you can directly perform the following operations without downloading third-party plug-ins: cd/usr/local/php/bin. when installing/pecl install memcache, the system prompts whether to enable session support. Enter no or yes as needed. The installation path is as follows: /usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/memcache. so needs to be manually configured to php. in ini, add the following content to enable memcache extension: extension = memcache. so supplement: after installing the Memcache extension in PHP, a problem is found, and the SESSION will be lost. This may be because no port 11211 is added to the firewall when the Memcached server is installed, After the firewall rules are modified, everything is normal. PHP memcached extension installation (note here is memcached non memcache) wget https://launchpad.net/libmemcached/1.0/1.0.16/+download/libmemcached-1.0.16.tar.gz tar-zxvf libmemcached-1.0.16.tar.gz cd libmemcached-1.0.16. /configure -- prefix =/usr/local/libmemcached -- with-memcached make & make install wget http://pecl.php.net/get/memcached-2.2.0.tgz tar zxvf memcached-2.2.0.tgz cd memcached-2.2.0/usr/local/php/bin/phpize. /Configure -- with-php-config =/usr/local/php/bin/php-config make & make install vi/usr/local/php/etc/php. ini with extension = memcached. so restart the service. 6. PHP project distributed several methods for synchronizing Sessions Using Memcache 1. directly modify php. ini configuration file session. save_handler = memcache session. save_path = "tcp: // 127.0.0.100: 11211" 2. Use. htaccess file php_value session. save_handler "memcache" php_value session. save_path "tcp: // 127.0.0.1: 11211" 3. modify the configuration ini_set ("session. save_handler "," memcache "); ini_set (" session. save_path "," tcp: // 127.0.0.100: 11211 "); The above is just a simple description. Generally, distributed systems have server permissions, so we recommend the first one.

Related Article

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.