Application memcached of the cache server in Linux
Source: Internet
Author: User
Memcached, an application of the cache server in Linux, is an enterprise application in Linux. For details, refer to the following section. I. environment requirements
Installing Memcached requires the support of the libevent library. Therefore, check whether libevent is installed before installing Memcached. The test environment also requires the support of PHP. This article assumes that PHP has been installed in the/usr/local/php Directory, that is, when compiling PHP, use the perfix parameter to specify the directory (-- prefix =/usr/local/php)
3. Install software
1. Install libevent
# Tar libevent-1.2.tar.gz
# Cd libevent-1.2
#./Configure -- prefix =/usr/local/libevent
# Ln-s/usr/local/libevent/lib/libevent-1.2.so.1/usr/lib
It is required to connect the symbol to memcache.
2. Install memcached
# Tar-zxvf memcached-1.2.0.tar.gz
# Cd memcached-1.2.0
#./Configure -- prefix =/usr/local/memcached
# Make
# Make install
Start memcached
/Usr/local/memcached/bin/memcached-d-m 20-p 11211-u apache
To enable Automatic startup, add a line in/etc/rc. d/rc. local.
3. Install the memcache PHP Module
# Tar-zxvf memcache-2.1.0.tgz
# Cd memcache-2.1.0 // ls found only a few files
#/Usr/local/php/bin/phpize // After compilation, many files are found, with more configure files
#./Configure -- enable-memcache -- with-php-config =/usr/local/php/bin/php-config -- with-zlib-dir
# Make
# Make install
Prompt:
Installing shared extensions:/usr/local/php/lib/php/extensions/no-debug-non-zts-20020429/
4. Modify php. ini
If php is not specified during php installation. you can use the phpinfo function of php to check the position of the ini, and then modify the corresponding php. ini, which is under/usr/local/php by default, but this file does not exist below, So copy it to the original file.
Cp php. ini-recommended/usr/local/php. ini
5. Check whether the test is successful.
Restart apache and write a test code.
$ Memcache = new Memcache; // create a memcache object
$ Memcache-> connect ('localhost', 11211) or die ("cocould not connect"); // connect to the Memcached Server
$ Memcache-> set ('key', 'test ');
// Set a variable to the memory. The name is key and the value is test.
$ Get_value = keys $ memcache-> get ('key'); // retrieves the key value from the memory.
Echo response $ get_value;
?>
If "test" is displayed, the installation is successful. If an error is reported, reinstall it!
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.