Method of installing Memcache cache server on Linux

  

Memcache cache is a good software, here is the method of installing under Linux:

The server side mainly installs 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 library libevent for Socket processing, so you need to install libevent, the latest version of libevent is Libevent-1.3. (If your system has libevent installed, you don't need to install it): http://www.monkey.org/~provos/libevent/Download: http://www.monkey.org/~provos/libevent-1.3. Tar.gz

Download these two things directly with the wget command. After downloading the source file. 1. Install libevent first. This thing needs to specify an installation path when configuring, ie ./configure –prefix=/usr; then make; then make install; 2. install memcached, just need to specify the installation path of libevent in configuration. /configure –with-libevent=/usr; Then make; then make install; this completes the installation of the Memcache server under 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:# tar zxvf libevent-1.2.tar. Gz# cd libevent-1.2# ./configure –prefix=/usr# make# make install

3.Test if libevent is installed successfully: # ls -al /usr/lib |  Grep libeventlrwxrwxrwx 1 root root 21 11?? 12 17:38 libevent-1.2.so.1 -> libevent-1.2.so.1.0.3-rwxr-xr-x 1 root root 263546 11?? 12 17:38 libevent -1.2.so.1.0.3-rw-r–r– 1 root root 454156 11?? 12 17:38 libevent.a-rwxr-xr-x 1 root root 811 11?? 12 17:38 libevent.lalrwxrwxrwx 1 Root root 21 11?? 12 17:38 libevent.so -> libevent-1.2.so.1.0.3 is not bad, they are installed.

4. Install memcached, and also specify the installation location of 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 an error occurs in the middle, please check the error message carefully and configure or add the corresponding library or path according to the error message. After the installation is complete, put memcached in /usr/local/bin/memcached,

5. Test whether the memcached is successfully installed: # ls -al /usr/local/bin/mem*-rwxr-xr-x 1 root root 137986 11?? 12 17:39 /usr/local/bin/memcached-rwxr-xr-x 1 root root 140179 11?? 12 17:39 /usr/local/bin/memcached-debug

Install Memcache's PHP
extension 1. Select the version of memcache you want to download at http://pecl.php.net/package/memcache. 2. Install PHP's memcache extension

tar vxzf memcache-2.2.1.tgzcd memcache-2.2.1/usr/local/php/bin/phpize./configure –enable-memcache –with-php -config=/usr/local/php/bin/php-config –with-zlib-dirmakemake install

3. After the above installation, there will be a prompt like this:

Installing shared Extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-2007xxxx/

4.Modify extension_dir = “./” in php.ini to < Br>

extension_dir = “/usr/local/php/lib/php/extensions/no-debug-non-zts-2007xxxx/”

5. Add a line to load the memcache extension: Extension=memcache.somemcached basic settings:

1. Start 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 is the amount of memory allocated to Memcache, the unit is MB, I am 10MB here, -u is running Memcache User, I am root here, -l is the server IP address of the listener, if there is more Address, I specified the server's IP address 192.168.0.200, -p is the port to set Memcache listening, I set here 12000, preferably more than 1024 port, -c option is the maximum number of concurrent connections running, The default is 1024, I set 256 here, according to the load of your server, -P is the pid file to save Memcache, I saved it here at /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 there is output This is a test!, it means the environment is built successfully. 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!& rsquo;, 0, 60); $val = $mem->get(’key’);echo $val;?>

Copyright © Windows knowledge All Rights Reserved