Linux memcache server-side installation
Server side is mainly installed Memcache server side, the latest version is memcached-1.3.0.
Download: http://www.danga.com/memcached/dist/memcached-1.2.5.tar.gz
In addition, Memcache used libevent This library for socket processing, so also need to install the latest version of Libevent,libevent is libevent-1.3. (If your system has libevent installed, you may not need to install it)
Official website: http://www.monkey.org/~provos/libevent/
Download: http://www.monkey.org/~provos/libevent-1.3.tar.gz
Download these two items directly with the wget command. After downloading back to the source file.
1. Install Libevent first. This thing needs to be configured to specify an installation path, i.e../configure–prefix=/usr; then make; then make install;
2. Reinstall the memcached, just need to specify the Libevent installation path in the configuration, that is./configure–with-libevent=/usr; then make; then make install;
This completes the Linux Memcache server-side installation. The detailed approach is as follows:
1. Download the memcached and libevent separately and put them in the/tmp directory:
# cd/tmp
# wget http://www.danga.com/memcached/dist/memcached-1.2.5.tar.gz
# wget http://www.monkey.org/~provos/libevent-1.2.tar.gz
2. Install Libevent First:
# tar ZXVF libevent-1.2.tar.gz
# CD libevent-1.2
#./CONFIGURE–PREFIX=/USR
# make
# make Install
3. Test whether the Libevent is installed successfully:
# Ls-al/usr/lib | grep libevent
lrwxrwxrwx 1 root root 21 11?? 17:38 libevent-1.2.so.1-> libevent-1.2.so.1.0.3
-rwxr-xr-x 1 root root 263546 11?? 17:38 libevent-1.2.so.1.0.3
-rw-r–r–1 root root 454156 11?? 17:38 LIBEVENT.A
-rwxr-xr-x 1 root root 811 11?? 17:38 libevent.la
lrwxrwxrwx 1 root root 21 11?? 17:38 libevent.so-> libevent-1.2.so.1.0.3
It's all right, it's all set up.
4. Install memcached, also need to install the designated Libevent installation location:
# cd/tmp
# tar ZXVF memcached-1.2.0.tar.gz
# CD memcached-1.2.0
#./CONFIGURE–WITH-LIBEVENT=/USR
# make
# make Install
If there is an error in the middle, please check the errors carefully, and configure or add the corresponding libraries or paths according to the error message.
When the installation is complete, the memcached will be placed in the/usr/local/bin/memcached,
5. Test for successful installation of memcached:
# ls-al/usr/local/mem*
-rwxr-xr-x 1 root root 137986 11?? 17:39/usr/local/bin/memcached
-rwxr-xr-x 1 root root 140179 11?? 17:39/usr/local/bin/memcached-debug
View Status: Service memcached status/restart/stop
View Process: Ps-ef | grep memcached
《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《
http://php.net/manual/zh/memcached.add.php
Installing Memcache PHP Extensions
1. Select the Memcache version that you want to download in Http://pecl.php.net/package/memcache.
2. Install the PHP memcache extension
Tar vxzf memcache-2.2.1.tgz
CD memcache-2.2.1
/usr/local/php/bin/phpize
./configure–enable-memcache--with-php-config=/usr/local/php/bin/php-config--with-zlib-dir
Make
Make install
3. The above installation will have a similar hint:
Installing Shared extensions:/usr/local/php/lib/php/extensions/no-debug-non-zts-2007xxxx/
4. Change the Extension_dir = "./" in php.ini to
Extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-2007xxxx/"
5. Add a row to load the memcache extension: extension=memcache.so
Basic Settings for memcached:
1. Start the Memcache server side:
#/usr/local/bin/memcached-d-M 10-u root-l 192.168.0.200-p 12000-c 256-p/tmp/memcached.pid
The-D option is to start a daemon,
-M is the amount of memory allocated to Memcache, in megabytes, I am 10MB here,
-U is the user running memcache, I am here root,
-L is a listening server IP address, if there are more than one address, I specify the IP address of the server 192.168.0.200,
-P is the port that sets the memcache listening, I set 12000 here, preferably 1024 or more ports,
The-c option is the maximum number of concurrent connections to run, the default is 1024, I set 256 here, according to the load of your server to set,
-P is set to save the Memcache pid file, which I am here to save in/tmp/memcached.pid,
2. If you want to end the memcache process, execute:
# Kill ' Cat/tmp/memcached.pid '
You can also start multiple daemons, but the ports cannot be duplicated.
3. Restart Apache,service httpd restart
Memcache Environment test:
Run the following PHP file, if the output is a test!, it means that the environment has been built successfully. began to appreciate the charm of memcache.
< PHP
$mem = new Memcache;
$mem->connect ("127.0.0.1″, 11211");
$mem->set (' key ', ' This is a test! ', 0, 60);
$val = $mem->get (' key ');
Echo $val;
?>
-----------------------------
Use Yum to install
Install memcache support for PHP under CentOS5
--------------------------------------------------------------------------------
After installing the CentOS5, because of yum this very useful Package Manager, we basically do not have to manually step by step to configure,make,make install.
As long as the simple run Yum command can be done, if you still need to manually compile, please refer to the attached reference document at the end of the article.
1. Check and install the third party software warehouse
Standard CENTOS5 software warehouse inside there is no memcache the corresponding package, do not believe you run
Yum Search Memcache
Look at the results, are not prompted as follows.
Loading "Installonlyn" plugin
Setting up Install Process
Setting up repositories
Reading repository metadata in from local files
Parsing Package Install arguments
Nothing todo
So, our first step is to import the third party software warehouse, here is recommended Dag Wieers library (now called Rpmforge), the installation method is as follows:
To the Web http://dag.wieers.com/rpm/packages/rpmforge-release/of the installation library, find the right package, in fact, very simple, We are centos5.0, because it is with the Red Hat Enterprise version 5.0 of the same source compiled, then want to be rhel5.0 can, the alternative is only the following two
rpmforge-release-0.3.6-1.el5.rf.i386.rpm Fri 2007 KB Red Hat EL 5-i386
rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm Fri 2007 KB Red Hat EL 5-x86_64
My 32-bit system, I chose the above address to download, if it is 64-bit, choose the following, hehe.
[Root@localhost src]# wget http://dag.wieers.com/rpm/packages/r...l5.rf.i386.rpm
[Root@localhost src]# RPM-IVH rpmforge-release-0.3.6-1.el5.rf.i386.rpm
There's no other clue, that's almost good. We will be able to install our memcache-related modules.
2, find the relevant software packages
Our version library index is automatically updated when looking up, as can be seen from below. We can find that there are two packages to be fitted, one is memcache, the other is Php-pecl-memecache. There is a new discovery, Python version of the Memcache client also have, cool AH.
[Root@localhost src]# Yum Search memcache
Loading "Installonlyn" plugin
Setting up repositories
Update 100% |=========================| 951 B 00:00
Rpmforge 100% |=========================| 1.1 KB 00:00
Base 100% |=========================| 1.1 KB 00:00
Addons 100% |=========================| 951 B 00:00
Extras 100% |=========================| 1.1 KB 00:00
Reading repository metadata in from local files
primary.xml.gz 100% |=========================| 1.1 MB 02:07
Rpmforge: ################################################## 3907/3907
Added 3907 new packages, deleted 0 in 13.20 seconds
primary.xml.gz 100% |=========================| Notoginseng KB 00:00
Extras: ################################################## 145/145
Added new packages, deleted 0 in 0.16 seconds
php-pecl-memcache.x86_64 2.0.4-1.EL5.RF Rpmforge
Matched from:
Php-pecl-memcache
PECL package to use the memcached distributed caching system
Memcached is a caching daemon designed especially for dynamic Web applications
To decrease the database load by storing objects in memory. This extension allows
You to the work with memcached through handy OO and procedural interfaces.
Http://pecl.php.net/package/memcache
php-pecl-memcache.x86_64 2.1.2-1.EL5.RF Rpmforge
Matched from:
Php-pecl-memcache
PECL package to use the memcached distributed caching system
Memcached is a caching daemon designed especially for dynamic Web applications
To decrease the database load by storing objects in memory. This extension allows
You to the work with memcached through handy OO and procedural interfaces.
Http://pecl.php.net/package/memcache
Python-memcached.noarch 1.31-1.EL5.RF Rpmforge
Matched from:
Python-memcached
Python interface to the memcached memory cache daemon
Python interface to the memcached memory cache daemon.
ftp://ftp.tummy.com/pub/python-memcached/
memcached.x86_64 1.1.13-4.EL5.RF Rpmforge
Matched from:
Memcached
Memcached is a high-performance, distributed memory object caching system,
Generic in nature, but intended for use in speeding up dynamic web
Applications by alleviating database load.
http://www.danga.com/memcached/
memcached.x86_64 1.2.1-3.EL5.RF Rpmforge
Matched from:
Memcached
Memcached is a high-performance, distributed memory object caching system,
Generic in nature, but intended for use in speeding up dynamic web
Applications by alleviating database load.
http://www.danga.com/memcached/
memcached.x86_64 1.1.13-5.EL5.RF Rpmforge
Matched from:
Memcached
Memcached is a high-performance, distributed memory object caching system,
Generic in nature, but intended for use in speeding up dynamic web
Applications by alleviating database load.
http://www.danga.com/memcached/
memcached.x86_64 1.2.1-4.EL5.RF Rpmforge
Matched from:
Memcached
Memcached is a high-performance, distributed memory object caching system,
Generic in nature, but intended for use in speeding up dynamic web
Applications by alleviating database load.
http://www.danga.com/memcached/
memcached.x86_64 1.2.2-1.EL5.RF Rpmforge
Matched from:
Memcached
Memcached is a high-performance, distributed memory object caching system,
Generic in nature, but intended for use in speeding up dynamic web
Applications by alleviating database load.
http://www.danga.com/memcached/
Python-openid.noarch 1.2.0-1.EL5.RF Rpmforge
Matched from:
The OpenID library with batteries included.
The Library features:
Refined and Easy-to-use APIs,
Extensive documentation,
Many storage implemetations including file-based, SQL, and memcached,
Simple examples-help-get started and
Licensed under the LGPL.
3. Installation and Verification
[Root@localhost src]# yum install–enablerepo=rpmforge memcached Php-pecl-memcache
[Root@localhost src]# Memcached-h
Memcached 1.2.2
[Root@localhost src]# Php-m|grep memcache
Memcache