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 website and reducing the reading and writing pressure of the backend database.
Experimental environment: CentOS 6.6 x86_64
Lamp environment built: PHP version 5.6.8, Apache version 2.4.12
1, before installing the 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 compilation and 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, Client Installation 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 following error has been executed:
/usr/local/src/memcache-2.2.3/memcache.c: in function ' php_mmc_connect ':/ usr/local/src/memcache-2.2.3/memcache.c:1902: error: Too few arguments were supplied to the function ' Zend_list_insert '/usr/local/src/ memcache-2.2.3/memcache.c:1919: error: There are too few arguments provided to the function ' Zend_list_insert '/usr/local/src/memcache-2.2.3/memcache.c: :/usr/local/src/memcache-2.2.3/memcache.c:1975: error in function ' Zif_memcache_add_server ': Supplied to function ' Zend_is_ Callable ' argument too few/usr/local/src/memcache-2.2.3/memcache.c:2003: error: the argument supplied to the function ' Zend_list_insert ' is too small/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: The argument supplied to the function ' zend_is_callable ' is too small/usr/local/src/memcache-2.2.3/memcache.c: the function ' MMC_ Find_persistent ':/usr/local/src/memcache-2.2.3/memcache.c:2159: error: Too few arguments are provided to the function ' Zend_list_insert '/usr/ local/src/memcache-2.2.3/memcache.c:2177: error: Too few arguments were supplied to the function ' Zend_list_insert ' Make: *** [memcache.lo ] Error 1
Modify according to the error:
VI memcache.c
Will all: Zend_list_insert (pool, le_memcache_pool);
Instead: Zend_list_insert (pool, Le_memcache_pool tsrmls_cc);
Will 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;
# Make installinstalling shared extensions:/usr/local/php/lib/php/extensions/no-debug-zts-20131226/
The Memcache.so module after installation is in the path above;
# Vi/usr/local/php/etc/php.ini
Added on last line:extension= "memcache.so"
After saving the exit, restart Apache, use Php-m to view the installed Memcache module, or in the browser access phpinfo.php view;
To start the memcached server:
#/usr/local/memcached/bin/memcached-d-u root-m 256-p 11211-l localhost
-D is to start a daemon,
-m behind specifies how much memory memecached uses, in units of M
-P Specify memcached boot port
-l Specifies the IP of the binding
-u Specifies to start as an account
After starting the error, unable to find the Libevent module;
/usr/local/memcached/bin/memcached:error while loading shared libraries: Libevent-1.4.so.2:cannot Open Shared object File:no such file or directory
You need to copy or link the libevent-1.4.so.2 to the/usr/lib64 (x86_64-bit system, the 32-bit/usr/lib directory), otherwise memcached will not load properly.
# cp/usr/local/libevent/lib/libevent-1.4.so.2/usr/lib64
Memcache environment test, write a PHP file, under the site root directory
[email protected] 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 the Web page to access ip/1.php if the Hello World description is configured successfully.
# curl-xlocalhost:80 192.168.4.231/1.phphello World
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s3.51cto.com/wyfs02/m02/6f/f1/wkiom1wt82pbkz6jaaa5_r0ap0y138.jpg "title=" 1.jpg "alt=" wKiom1Wt82PBkZ6jAAA5_ R0ap0y138.jpg "/>
This article is from the "Model Student's Learning blog" blog, please be sure to keep this source http://mofansheng.blog.51cto.com/8792265/1676746
Install PHP extensions memcache under Linux