Linux under Memcache server-side installation
Server side is mainly installed Memcache server side, the current version is memcached-1.3.0.
Download: http://www.danga.com/memcached/dist/memcached-1.2.2.tar.gz
In addition, Memcache used the libevent this library for socket processing, so you also need to install the latest version of Libevent,libevent is libevent-1.3. (If your system already has libevent installed, you can not 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 with an installation path, i.e../configure–prefix=/usr; then make; then make install;
2. Install the memcached again, just need to specify the installation path of libevent when configuring the./configure–with-libevent=/usr; then make; then make install;
This completes the installation of Linux under the Memcache server side. The detailed methods are 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.0.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
Good, all installed.
4. Install the memcached and require the installation location of the specified libevent in the installation:
# 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 carefully check the errors, follow the error message to configure or add the appropriate library or path.
When the installation is complete, the memcached will be put into/usr/local/bin/memcached,
5. Test whether the memcached is installed successfully:
# ls-al/usr/local/bin/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
Installing PHP extensions for Memcache
1. Select the Memcache version you want to download in the Http://pecl.php.net/package/memcache.
2. Installing 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. There will be a hint like this after the installation is complete:
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 server side of the memcache:
#/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'm 10MB,
-U is the user running memcache, I am root here,
-L is the server IP address of the listener, if there are multiple addresses, I specify the server IP address 192.168.0.200,
-P is the port that sets Memcache listening, I set here 12000, preferably more than 1024 ports,
The-c option is the maximum number of concurrent connections to run, the default is 1024, I set the 256 here, according to the load of your server to set,
-P is set to save memcache PID file, 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 Environmental Testing :
Run the following PHP file, if there is output this is a test!, it indicates that the environment was built successfully. Begin 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;
?>