Memcache's job is to maintain a huge hash table in the memory of a dedicated machine to store some of the arrays and files that are often read and written, thus greatly improving the efficiency of the Web site and reducing the reading and writing pressure of the back-end database.
Experimental environment: CentOS 6.6 x86_64
Lamp Environment Completed: PHP version 5.6.8, Apache version 2.4.12
1, before installing memcached need to install libevent support:
# wget http://syslab.comsenz.com/downloads/linux/libevent-1.4.12-stable.tar.gz
# tar ZXVF libevent-1.4.12-stable.tar.gz
# cd libevent-1.4.12-stable
#./configure--prefix=/usr/local/libevent
# Make && make install
2, server-side memcached compiler installation
# wget http://syslab.comsenz.com/downloads/linux/memcached-1.4.5.tar.gz
# tar zxvf memcached-1.4.5.tar.gz
# CD memcached-1.4.5
#/configure--prefix=/usr/local/memcached--with-libevent=/usr/local/libevent/
# make && make install
3, the client installs Memcache steps :
# wget http://www.lishiming.net/data/attachment/forum/memcache-2.2.3.tgz
# tar zxvf memcache-2.2.3.tgz
# CD memcache-2.2.3
#/usr/local/php/bin/phpize
#/configure--with-php-config=/usr/local/php/bin/php-config- -enable-memcache
# Make
The error following the execution of make is as follows:
/USR/LOCAL/SRC/MEMCACHE-2.2.3/MEMCACHE.C: In the function ' Php_mmc_connect ':
/usr/local/src/memcache-2.2.3/memcache.c : 1902: Error: Too few arguments supplied to function ' Zend_list_insert '
/usr/local/src/memcache-2.2.3/memcache.c:1919: Error: Supplied to function ' Zend_list_ Insert ' argument too little
/usr/local/src/memcache-2.2.3/memcache.c: in function ' Zif_memcache_add_server ':
/usr/local/src/ memcache-2.2.3/memcache.c:1975: Error: Too few arguments are supplied to the function ' zend_is_callable '
/usr/local/src/memcache-2.2.3/memcache.c : 2003: Error: Too few arguments provided to function ' Zend_list_insert '
/usr/local/src/memcache-2.2.3/memcache.c: in function ' Zif_memcache_set_server _params ':
/usr/local/src/memcache-2.2.3/memcache.c:2059: Error: Too few arguments supplied to function ' zend_is_callable '
/usr/local/ SRC/MEMCACHE-2.2.3/MEMCACHE.C: In the function ' mmc_find_persistent ':
/usr/local/src/memcache-2.2.3/memcache.c:2159: Error: Too few arguments supplied to function ' Zend_list_insert '
/usr/local/src/memcache-2.2.3/memcache.c:2177: Error: Supplied to function ' Zend_list_ Insert ' too few arguments make
: * * * [Memcache.lo] Error 1
According to the error, modify:
VI memcache.c
Will be all: Zend_list_insert (pool, le_memcache_pool);
Instead: Zend_list_insert (pool, Le_memcache_pool tsrmls_cc);
Will be all: Zend_list_insert (MMC, le_pmemcache);
Instead: Zend_list_insert (MMC, Le_pmemcache tsrmls_cc);
Speak all: if (!zend_is_callable (failure_callback, 0, NULL))
Instead: if (!zend_is_callable (failure_callback, 0, NULL, NULL))
After the modification is complete, make the compilation again;
Copy Code code as follows:
# make Install
Installing Shared extensions:/usr/local/php/lib/php/extensions/no-debug-zts-20131226/
After the installation completes the Memcache.so module in the path above;
Copy Code code as follows:
# Vi/usr/local/php/etc/php.ini
Add on last line: extension= "memcache.so"
After you save the exit, restart Apache, use Php-m to view the Memcache modules that have been installed, or view the phpinfo.php in the browser.
Start the memcached service side:
#/usr/local/memcached/bin/memcached-d-u root-m 256-p 11211-l localhost
-D is to start a daemon,
-m specifies how much memory the memecached uses, the unit is M.
-p Specifies the memcached boot port
-l Specifies the bound IP
-u Specifies to start as an account
After starting the error, can not find the Libevent module;
/usr/local/memcached/bin/memcached:error while loading shared libraries:libevent-1.4.so.2:cannot open Shared object fi Le:no such file or directory
You need to copy or link the libevent-1.4.so.2 to/usr/lib64 (x86_64 bit system, 32-bit/usr/lib directory), otherwise the memcached will not load properly.
# cp/usr/local/libevent/lib/libevent-1.4.so.2/usr/lib64
Memcache environment test, write a php file, in the site root directory
[Root@localhost htdocs]# cat 1.php
<?php
$mem = new Memcache;
$mem->connect ("localhost", 11211);
$mem->set (' Test ', ' Hello World ', 0,60);
echo $mem->get (' test ');
? >
Use Curl or Web Access ip/1.php if the Hello World description configuration succeeds.
# curl-xlocalhost:80 192.168.4.231/1.php
Hello World
Hello World
This is the article with you to share the Linux installation of PHP expansion Memcache method, I hope you can enjoy.