Website acceleration VPS: Installing memcache and memcached

Source: Internet
Author: User
Tags vps

Original address: http://www.zhixiu86.com/bencandy.php? Fid-103-id-557-page-1.htm

What is memcache?

Memcache is a free and openSource code, High-performance, allocated memory object cache system. Used to accelerate Dynamic Web ApplicationsProgramTo reduce the database load.

It can cope with any number of connections and use non-blocking network I/O. Because its working mechanism is to open up a space in the memory, and then create a hashtable, memcached self-manages these hashtable.

What is memcached?

Memcached is the main program file of the memcache system. It runs on one or more servers in the form of a daemon. It accepts connection operations from the client at any time and uses shared memory to access data.

What is memcache in PHP? Memcache mentioned in PHP is one of the extensions supported by PHP for connecting to memecached (which can be viewed by phpinfo), such as mbstring and eaccelerator.

Simply put

Memcache is the name of the total cache system project, which is easy to be confused with memcache in PHP.

We often mention that memcache is actually a memcache in PHP, that is, PHP's memcached extension support.

We often mention that memcached is the server-side main program file and the server-side installer.

To make your program fly, you must install the memcached server program and the memcached extension of PHP. If you want to use memcache for the cache system, both memcache and memcached must be installed.

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 sentence uses the directory/usr/local/PHP where PHP is located as an example. If your PHP has changed, replace the/usr/local/PHP section in the following sentence.

#/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 PhP Extension

# Vi/etc/PHP. INI (/etc/PHP. the INI address is my PHP. INI location, if you do not know your php. where is the ini? # Find/-name PHP. INI, or pass a probe phpinfo to find the configuration file (PHP. INI) path) in PHP. INI location.

Add at the end

Press I on the disk to start editing.

CTRL + F pull the page to the bottom and add it before [Zend]

Extension_dir = "/usr/local/PHP/lib/PHP/extensions/no-debug-non-zts-20060613 /"
Extension = memcache. So

Press ESC and then enter

: WQ

Save and exit

Restart your web server, such as Apache

/Etc/init. d/httpd restart

Next, refresh the PHP probe and check if there is any such probe. If yes, it is installed.

Memcache
Version 2.2.5memcache
Version 2.2.5

 

Install memcached

To install memcached, install libevent first.

If centos is used, yum can be installed.

# Yum install libevent-devel

If the yum system is not supported, you can install libevent like this.

# 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

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/local/memcached
# Make & make install

After the installation, start memcached and allocate 32 MB of memory (32 indicates the number of memory used, which can be modified as needed)

/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 disk to start editing.

Add at last

/Usr/local/memcached/bin/memcached-D-M 32-l 127.0.0.1-P 11211-u Root

Press ESC and then enter

: WQ

Save and exit

If needed, you can reboot it, but it should have taken effect without reboot ~

Acceleration Effect Test

Use discuz X1 with no load for a test. If it is not started

GMT + 8, Processed in 0.038893 second (s), 2 queries.

The effect after the cache is enabled, but the VPs is not as effective as adding eaccelerato to the cache.

GMT + 8, Processed in 0.008383 second (s), 2 queries, memcache on.

Complete

Install memcached

To install memcached, install libevent first.

If centos is used, yum can be installed.

# Yum install libevent-devel

If the yum system is not supported, you can install libevent like this.

# 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

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/local/memcached
# Make & make install

After the installation, start memcached and allocate 32 MB of memory (32 indicates the number of memory used, which can be modified as needed)

/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 disk to start editing.

Add at last

/Usr/local/memcached/bin/memcached-D-M 32-l 127.0.0.1-P 11211-u Root

Press ESC and then enter

: WQ

Save and exit

If needed, you can reboot it, but it should have taken effect without reboot ~

Acceleration Effect Test

Use discuz X1 with no load for a test. If it is not started

GMT + 8, Processed in 0.038893 second (s), 2 queries.

The effect after the cache is enabled, but the VPs is not as effective as adding eaccelerato to the cache.

GMT + 8, Processed in 0.008383 second (s), 2 queries, memcache on.

Complete

Original address: http://www.zhixiu86.com/bencandy.php? Fid-103-id-557-page-1.htm

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.