memcached installation and PHP two extension software installation (Memcache, memcached)

Source: Internet
Author: User

Baidu Cloud Installation package: Http://pan.baidu.com/s/1pKZeDwn K3AP

1, installation memcached

Memcached is based on Libevent event handling, so its installation relies on libevent. So we first need to install the libevent and then install the memcached.

Libevent Official website: http://libevent.org/

Memcached Official website: http://www.danga.com/memcached

Install Libevent:

# TAR–ZXVF libevent-1.4.9-stable.tar.gz # CD libevent-1.4.9-stable # ./configue--prefix=/usr # Make&make Install

Install memcached:

# TAR–ZXVF memcached-1.4.25.tar.gz # CD memcached-1.4.25 # ./configue--with-libevent=/usr--prefix=/usr/local # Make&make Install

Trial run:

# /usr/local/bin/memcached-u User Name # ps–a|grep memcached       (see if there is a memcached process)

Specific startup parameters and directives can be consulted: http://www.cnblogs.com/phpstudy2015-6/p/6653199.html

2. Install the memcache extension in PHP

Official website Download: Http://pecl.php.net/package/memcache

Installation:

# Tar zxvf memcache-2.2.4.tgz # CD memcache-2.2.4 CD # /usr/local/php/bin/phpize # ./configure--with-php-config=/usr/local/php/bin/php-config # Make&make Install

Configuration:

(generated. so extension file)

# ls-l/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/memcache.so # Vi/usr/local/php/lib/php.ini

Add extension = memcache.so

Save, restart Apache

Test:

1, the establishment of a test.php file, the ability to generate Memcache objects means that the installation extension is successful

<? PHP     $m=new  memcache ();     Var_dump ($m);? >

2, view phpinfo ();

3, Installation libmemcached

Official website Download: https://launchpad.net/libmemcached/+download

Brief description of the software:

Libmemcached is the memcached C client, it has the advantages of low memory, line Cheng and other characteristics.

where libmemcached version 1.0.9 needs to be installed with advanced GCC compilation (it relies on a higher-level version of the GCC library)

If the GCC version is too low:

Yum Install gcc44 gcc44-c++ libstdc++44-devel

Installation process:

# Tar zxvf libmemcached-1.0.18.tar.gz # CD libmemcached-1.0.18 # ./configure--prefix=/usr/local/libmemcached--with-memcached # make  && make  install

"Generally, gcc version OK, installation will be OK"

Installation issues to be aware of:

1, the best can set the installation directory,--prefix

"The following two are from the Internet, I did not encounter these two problems during installation"

2, the installation process do not forget, –with-memcached, otherwise you will be prompted

Checking for memcached ... no
Configure:error: "Could not find memcached binary"

3, your memcached is not 1.2.4 above, if not will prompt you

clients/ms_thread.o:in function ' Ms_setup_thread ':
/home/zhangy/libmemcached-0.42/clients/ms_thread.c:225:undefined reference to ' __sync_fetch_and_add_4′
Clients/ms_thread.o:/home/zhangy/libmemcached-0.42/clients/ms_thread.c:196:more undefined references to ' __sync_ Fetch_and_add_4′follow
Collect2:ld returned 1 exit status
MAKE[2]: * * * [Clients/memslap] Error 1
MAKE[2]: Leaving directory '/home/zhangy/libmemcached-0.42′

The solution is –disable-64bit cflags= "-o3-march=i686″, if you do not use this 64-bit long data, I think the PHP extension Memcached,memcache is no different, It's no fun pretending to be a memcached.

4. Install the memcached extension in PHP

Memcached's 1.2.4 and above increase the CAS (Check and Set) protocol for concurrent processing of multiple trips to the same key. PHP extension memcache, does not support CAs, so we want to install memcached extension, memcached extension is based on libmemcached, so the first installation libmemcached.

The memcache extension in PHP is relative to the memcached extension, the memcache extension has been discontinued and has relatively few features, while the memcached extension has been maintained and updated with great functionality.

Official website Download: http://pecl.php.net/package/memcached

"Installing memcached Extension Notes"

If libmemcached is installed in a non-standard path, use --with-libmemcached-dir=dir to specify the path, dir is the prefix parameter when the libmemcached is installed. This path needs to include the file include/libmemcached/memcached.h .

If you want to support compression, you need to zlib. For non-standard installed zlib libraries, use --with-zlib-dir=dir to specify the zlib installation path, dir is the prefix parameter at Zib installation

The session processor support is turned on by default. If you want to turn it off, use the option --disable-memcached-session .

# TAR-ZXVF memcached-2.2.0.tgz # CD memcached-2.2.0 # /usr/lcoal/php/bin/phpize # ./configure--enable-memcached--with-php-config=/usr/local/php/bin/php-config--with-libmemcached-dir=/usr/ local/libmemcached--with-memcached--with-zlib-dir=/usr/local/zlib--enable-memcached-igbinary# Make && make install

"Note" At compile time:

"--with-zlib-dir=/usr/local/zlib": indicates that the compression function is used when the data is cached, and if it does not need to be compressed, it does not need to be installed. The installation method is as follows

"--enable-memcached-igbinary": Igbinary is a serialization tool that stores PHP data structures in a compact binary form, with improvements in both time and space to improve performance. To take this parameter, you need to install it. The installation method is as follows

View:

5, installation zlib and Igbinary

Official Download: http://www.zlib.net (zlib)

Http://pecl.php.net/package/igbinary (Igbinary)

"Install Zlib"

Tar-xvzf zlib-1.2.5.tar.gz # CD zlib-1.2.5.tar.gz # ./configure--prefix=/usr/local/zlib # Make && make install

"Installing Igbinary Extensions"

Igbinary is an extension in PHP

# TAR–ZXVF igbinary-1.1.1.tgz # CD igbinary-1.1.1 # /usr/lcoal/php/bin/phpize # ./configure # Make && make install

(These are some of their own ideas, if there is insufficient or wrong place please point out)

That leaves with the wind

Statement: This blog article for the original, only represents my work in the study in a certain time to summarize the views or conclusions. Please give the original link in the article page when reproduced

memcached installation and PHP two extension software installation (Memcache, memcached)

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.