Original post address: http://flash520.blog.163.com/blog/static/344144752009101052643557/
Linux memcached
17:26:43 | category:
Default category | font size subscription
How to Get discuz recently! Apply memcache to do some things and record the memcache installation process.
Install the memcache server in Linux
The server is mainly installed on the memcache server, the latest version is memcached-1.3.0.
Download: http://www.danga.com/memcached/dist/memcached-1.2.2.tar.gz
In addition, memcache uses the libevent library for socket processing, so you also need to install libevent, the latest version of libevent is the libevent-1.3. (If your system has already installed libevent, you do not need to install it)
Official Website: http://www.monkey.org /~ Provos/libevent/
Download: http://www.monkey.org /~ Provos/libevent-1.3.tar.gz
Use the wget command to directly download these two items.
1. Install libevent first. During configuration, You need to specify an installation path, that is,./configure-Prefix =/usr; then make install;
2. Install memcached again. You only need to specify the installation path of libevent during configuration, that is,./configure-with-libevent =/usr; then make install;
This completes the installation of the memcache server in Linux. The detailed method is as follows:
1. Download memcached and libevent respectively 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 successfully installed:
# Ls-Al/usr/lib | grep libevent
Lrwxrwxrwx 1 Root 21 11 ?? Libevent-1.2.so.1> libevent-1.2.so.1.0.3
-Rwxr-XR-x 1 Root 263546 11 ?? Libevent-1.2.so.1.0.3
-RW-r-1 Root 454156 11 ?? 12 libevent.
-Rwxr-XR-x 1 Root 811 11 ?? Libevent. La
Lrwxrwxrwx 1 Root 21 11 ?? 12 libevent. So-> libevent-1.2.so.1.0.3
Not bad. They all have been installed.
4. Install memcached and specify the libevent installation location during installation:
# Cd/tmp
# Tar zxvf memcached-1.2.0.tar.gz
# Cd memcached-1.2.0
#./Configure-with-libevent =/usr
# Make
# Make install
If an error is reported in the middle, check the error information carefully and configure or add the corresponding library or path according to the error information.
After the installation is complete, the memcached will be placed in/usr/local/bin/memcached,
5. Test whether memcached is successfully installed:
# Ls-Al/usr/local/bin/MEM *
-Rwxr-XR-x 1 Root 137986 11 ?? 12 :39/usr/local/bin/memcached
-Rwxr-XR-x 1 Root 140179 11 ?? 12 :39/usr/local/bin/memcached-Debug
Install the PHP extension of memcache
1. Select the desired memcache version in the http://pecl.php.net/package/memcache.
2. Install memcache extension for PHP
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. A message similar to this will appear after the above installation:
Installing shared extensions:/usr/local/PHP/lib/PHP/extensions/no-debug-non-zts-2007xxxx/
4. Modify extension_dir = "./" in PHP. ini
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 of memcached:
1. Start the memcache Server:
#/Usr/local/bin/memcached-D-M 10-u root-l 192.168.0.200-P 12000-C 256-P/tmp/memcached. PID
-D option is to start a daemon,
-M indicates the amount of memory allocated to memcache. The unit is mb. Here I am 10 MB,
-U is the user who runs memcache. Here I am root,
-L is the IP address of the listening server. If there are multiple IP addresses, I have specified the IP address 192.168.0.200,
-P is the port for memcache listening. I have set port 12000 here, preferably port 1024 or above,
-The "C" option is the maximum number of concurrent connections. The default value is 1024. I have set 256 here, which is based on the load of your server,
-P is the PID file for saving memcache. Here I save it in/tmp/memcached. PID,
2. to end the memcache process, run:
# Kill 'cat/tmp/memcached. Pi'
You can also start multiple daemon processes, but the ports cannot be repeated.
3. Restart Apache and service httpd restart
Test the memcache Environment:
Run the following PHP file. If this is a test! Is output !, Indicates that the environment is successfully set up. Start 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;
?>
Certificate -----------------------------------------------------------------------------------------------------------------------------------------------------------
Original post address: http://mr-lonely-hp.iteye.com/blog/1058491
Install the memcache server in Linux
The server is mainly installed on the memcache server, the latest version is memcached-1.3.0.
Download: http://www.danga.com/memcached/dist/memcached-1.2.2.tar.gz
In addition, memcache uses the libevent library for socket processing, so you also need to install libevent, the latest version of libevent is the libevent-1.3. (If your system has already installed libevent, you do not need to install it)
Official Website: http://www.monkey.org /~ Provos/libevent/
Download: http://www.monkey.org /~ Provos/libevent-1.3.tar.gz
Use the wget command to directly download these two items.
1. Install libevent first. During configuration, You need to specify an installation path, that is,./configure-Prefix =/usr; then make install;
2. Install memcached again. You only need to specify the installation path of libevent during configuration, that is,./configure-with-libevent =/usr; then make install;
This completes the installation of the memcache server in Linux. The detailed method is as follows:
1. Download memcached and libevent respectively 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 successfully installed:
# Ls-Al/usr/lib | grep libevent
Lrwxrwxrwx 1 Root 21 11 ?? Libevent-1.2.so.1> libevent-1.2.so.1.0.3
-Rwxr-XR-x 1 Root 263546 11 ?? Libevent-1.2.so.1.0.3
-RW-r-1 Root 454156 11 ?? 12 libevent.
-Rwxr-XR-x 1 Root 811 11 ?? Libevent. La
Lrwxrwxrwx 1 Root 21 11 ?? 12 libevent. So-> libevent-1.2.so.1.0.3
Not bad. They all have been installed.
4. Install memcached and specify the libevent installation location during installation:
# Cd/tmp
# Tar zxvf memcached-1.2.0.tar.gz
# Cd memcached-1.2.0
#./Configure-with-libevent =/usr
# Make
# Make install
If an error is reported in the middle, check the error information carefully and configure or add the corresponding library or path according to the error information.
After the installation is complete, the memcached will be placed in/usr/local/bin/memcached,
5. Test whether memcached is successfully installed:
# Ls-Al/usr/local/bin/MEM *
-Rwxr-XR-x 1 Root 137986 11 ?? 12 :39/usr/local/bin/memcached
-Rwxr-XR-x 1 Root 140179 11 ?? 12 :39/usr/local/bin/memcached-Debug
1. Start the memcache Server:
#/Usr/local/bin/memcached-D-M 10-u root-l 192.168.0.200-P 12000-C 256-P/tmp/memcached. PID
-D option is to start a daemon,
-M indicates the amount of memory allocated to memcache. The unit is mb. Here I am 10 MB,
-U is the user who runs memcache. Here I am root,
-L is the IP address of the listening server. If there are multiple IP addresses, I have specified the IP address 192.168.0.200,
-P is the port for memcache listening. I have set port 12000 here, preferably port 1024 or above,
-The "C" option is the maximum number of concurrent connections. The default value is 1024. I have set 256 here, which is based on the load of your server,
-P is the PID file for saving memcache. Here I save it in/tmp/memcached. PID,
2. To view the memcache process, run:
# Ps aux | grep memcached
3. to end the memcache process, run:
# Kill-9 PID (memcached)
# Kill 'cat/tmp/memcached. Pi'
You can also start multiple daemon processes, but the ports cannot be repeated.