Home > Backend Development > PHP Tutorial > Install memcache and memcached_PHP tutorial

Install memcache and memcached_PHP tutorial

WBOY
Release: 2016-07-20 11:09:30
Original
910 people have browsed it

Simply put

Memcache is the name of the general cache system project, which is easily confused with memcache in the PHP tutorial.

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 main program file of the server and the installation program of the server.

In order to make your program fly, you must install the memcached server program and the memcached extension of php, 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 refer to the directory where php is located as / usr/local/php as an example. If your php has changed, please replace the part of /usr/local/php in the sentences

# /usr/local/php/bin/phpize
# ./configure --enable-memcache --with-php-config=/usr/local/php/bin/php-config --with-zlib-dir
# make && make install

will memcache added php extension

# vi /etc/php.ini (/etc/php.ini address is the location of my php.ini. If you don’t know where your php.ini is, you can use # find / -name php.ini to search, or pass a probe phpinfo to find the location of php.ini in the configuration file (php.ini) path).

Add

to the end and press on the keyboard i Start editing

ctrl+f to scroll to the bottom and add

extension_dir = "/usr/local/php/lib/php/extensions/no-debug before [zend] -non-zts-20060613/"
extension=memcache.so

Press the esc key and enter

: wq

Save and exit

Restart your web server, such as apache

/etc/init.d/httpd restart

Next, refresh the php probe to see if this is available. If so, install it.

memcache
version 2.2.5memcache
version 2.2.5

Install memcached below

To install memcached, you first need to install libevent

If it is centos, you can install it with yum

# yum install libevent-devel

If the system does not support yum, 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

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

Installation After completion, start memcached and allocate 32m of memory (32 is the number of used memory, which can be modified 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 startup items

# vi /etc/rc.d/rc.local

Press i on the keyboard to start editing

Add

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

Press the esc key and enter

:wq

Save and exit

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

Acceleration effect test

Use Do a test with discuz x1 without any load. When it is not enabled,

gmt+8, 2010-9-12 09:08, processed in 0.038893 second(s), 2 queries.

Cache The effect after enabling it, but the overall feeling is that the effect in the vps tutorial is not as obvious as the effect of adding eaccelerato cache

gmt+8, 2010-9-12 09:08, processed in 0.008383 second(s), 2 queries, memcache on.

Complete

and install memcached below

To install memcached, you first need to install libevent

If it is centos, you can install it with yum

# yum install libevent-devel

If the system does not support yum, 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

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

After installation, start memcached and allocate 32m of memory (32 is the number of used memory, which can be modified 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 items

# vi /etc/rc.d/rc.local

Press i on the keyboard to start editing

Add

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

Press the esc key and enter

: wq

Save and exit

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

Acceleration effect test

Use discuz x1 with no load to do a test, when it is not enabled

gmt+8, 2010-9-12 09:08, processed in 0.038893 second(s), 2 queries.

The effect after caching is enabled, but the overall effect on vps is not as obvious as the effect of using eaccelerato cache

gmt+8, 2010-9-12 09:08, processed in 0.008383 second(s), 2 queries , memcache on.

Completed


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/444801.htmlTechArticleSimply put, memcache is the name of the general cache system project, which is easily confused with memcache in the PHP tutorial. We often mention that memcache is actually memcache in php, that is, php's memcached extension support. ...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template