Memcache and memcached installation process

  
                  

What is Memcache?

Memcache is a free and open source, high performance, allocated memory object caching system. Used to speed up dynamic web applications and reduce database load.

It can handle any number of connections, using non-blocking network IO. Since it works by opening up a space in memory and then building a HashTable, Memcached manages these HashTables.

What is Memcached?

Memcached is the main program file of Memcache system. It runs in one or more servers as a daemon, accepting client connection operations at any time, and using shared memory. Take data.

What is the Memcache in PHP? The memcache in php is one of the php support extensions for connecting Memecached (viewable with phpinfo), similar to mbstring, eAccelerator.

Simply say

Memcache is the total cache system project name, which is easily confused with Memcache in PHP.

We often mention that Memcache is actually Memcache in PHP, which is the Memcached extension support of PHP.

We often mention that Memcached is the server main program file, server installation program.

In order for your program to fly, you must install the memcached server program and PHP's Memcached extension, so if you want to use Memcache to cache the system, we need to install both memcache and memcached.

Install memcache # cd /usr/local/src # wget http://pecl.php.net/get/memcache-2.2.5.tgz # gzip -d memcache-2.2.5.tgz # tar Xvf memcache-2.2.5.tar # cd memcache-2.2.5

The following sentences are based on the directory where php is /usr/local/php. If your php changes, please replace it yourself. The part of /usr/local/php in a few sentences # /usr/local/php/bin/phpize # ./configure --enable-memcache --with-php-config=/usr/local/php/bin/php- Config --with-zlib-dir # make && make install

Add memcache to the php extension

# vi /etc/php.ini(/etc/php.ini is My php.ini location, if you don't know where your php.ini is, you can use # find /-name php.ini to find it, or pass a probe phpinfo and find Configuration File (php.ini) Path) The location of php.ini.

Add

at the end Press i on the keyboard to start editing

CTRL+F to pull the page to the bottom to add extension_dir before [Zend] "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/" ext Ension=memcache.so

Press Esc and enter

:wq

Save and exit

Restart your web server, such as apache /etc/Init.d/httpd restart

The following refresh the PHP probe, see if there is this, and some are installed memcache Version 2.2.5memcache Version 2.2.5 Install memcached

Install memcached first need to install and install libevent

If it is centos, you can install yum # yum install libevent-devel

If you do not support yum system, you can install libevent # cd /usr/local /src # wget http://www.monkey.org/~provos/libevent-1.4.12-stable.tar.gz # tar vxf libevent-1.4.12-stable.tar.gz # cd libevent-1.4.12 # ./configure --prefix=/usr/local/libevent # make && make install


Continue to install memcached # cd /usr/local/src # wget http://Cloud.github.com/downloads/saberma/saberma.github.com/memcached-1.4.4.tar.gz # tar vxf memcached-1.4.4.tar.gz # cd memcached-1.4.4 # ./configure -- Prefix=/usr/l Ocal/memcached # make && make install


After installation, start memcached and allocate 32m of memory (32 is the amount of memory used, you can modify it according to your own situation) /usr/local/Memcached/bin/memcached -d -m 32 -l 127.0.0.1 -p 11211 -u root

Add memcached to the startup item # vi /etc/rc.d/rc.local


Press i on the keyboard to start editing

Add

at the end /usr/local/memcached/bin/memcached -d -m 32 -l 127.0.0.1 -p 11211 -u root

Press Esc, then enter

:wq

Save and exit

If you need, you can reboot, but you don’t have to reboot. Effective~

Accelerated Effect Test

Test with Discuz X1 without any load, not enabled GMT+8, 2010-9-12 09:08, Processed in 0.038893 second(s ), 2 queries.

The effect of caching is enabled, but the overall feeling is not as good as the effect of adding cache to eAccelerato cache.

GMT+8, 2010-9-12 09:08, Processed in 0.008383 second(s), 2 queries, Memcache On.

You're done, finish the work! ~~

Copyright © Windows knowledge All Rights Reserved