Install memcached and two php extension software (memcache and memcached) and memcachedmemcache
Baidu cloud installation package: http://pan.baidu.com/s/1pKZeDwn k3ap
1. Install memcached
Memcached is a libevent-based event processing, so its installation depends on libevent. Therefore, we must first install libevent and then install memcached.
Libevent Official Website: http://libevent.org/
Memcached 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 username # ps-A | grep memcached (check whether the memcached process exists)
Specific startup parameters and instructions can refer to: http://www.cnblogs.com/phpstudy2015-6/p/6653199.html
2. Install memcache extension in PHP
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 and restart apache
Test:
1. Create a test. php file. If you can generate a memcache object, the extension is successfully installed.
<?php $m=new memcache(); Var_dump($m);?>
2. View phpinfo ();
3. Install libmemcached
Download: https://launchpad.net/libmemcached/+download
Software Description:
Libmemcached is the C client of memcached. It has the advantages of low memory and thread security.
Among them, libmemcached version 1.0.9 needs to be compiled and installed with advanced gcc (it depends on the gcc library of a more advanced version)
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
[In general, the gcc version is OK and installation is OK]
Notes for installation:
1. It is best to set the installation directory -- prefix
[The following two are from the Internet. I did not encounter these two problems during installation]
2. Do not forget to install it.-with-memcached. Otherwise, you will be prompted.
Checking for memcached... No
Configure: error: "cocould not find memcached binary"
3. Is your memcached above 1.2.4? If not, you will be prompted
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 ′
Solution is-disable-64bit CFLAGS = "-O3-march = i686", if you don't need this 64-bit long data, I want php to expand memcached, memcache will be no difference, it doesn't make much sense to install memcached.
4. Install the memcached extension in PHP
The CAS (Check and Set) protocol is added to the 1.2.4 and later versions of memcached to solve the concurrent processing problem of the multi-entry route of the same key. Php extension memcache does not support cas, so we need to install the memcached extension. The memcached extension is based on libmemcached, so we need to install libmemcached first.
Compared with the memcached extension in php, The memcache extension has stopped maintenance and has fewer functions. The memcached extension has been maintained and updated with powerful functions.
Download: http://pecl.php.net/package/memcached
[Notes for installing memcached extensions]
If libmemcached is installed in a non-standard path, use-- With-libmemcached-dir = DIRTo specify the path. DIR is the prefix parameter for libmemcached installation. This path must contain filesInclude/libmemcached/memcached. h.
Zlib is required to support compression. For non-standard zlib library, use-- With-zlib-dir = DIRTo specify the zlib installation path. DIR is the prefix parameter during zib installation.
The session processor is enabled by default. If you want to disable it, use-- Disable-memcached-session.
# tar -zxvf memcached-2.2.0.tgz# cd memcached-2.2.0# /usr/local/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 --disable-memcahed-sasl
# make && make install
Note:
"-- With-zlib-dir =/usr/local/zlib": indicates that the compression function is used to cache data. If compression is not required, you do not need to install it. The installation method is as follows:
"-- Enable-memcached-igbinary": igbinary is a serialization tool that stores php Data Structures in close binary format, improving both time and space, and improving performance. To include this parameter, you must install it. The installation method is as follows:
View:
5. Install zlib and igbinary
Http://www.zlib.net (zlib)
The 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
[Install the igbinary extension]
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
(The above are some of your own opinions. If you have any shortcomings or errors, please point them out)
Author: The leaf goes with the wind
Disclaimer: This blog post is original and only represents the point of view or conclusion I have summarized at a certain time in my work and study. When reprinting, please provide the original article link clearly on the Article Page