Install Memcache in Linux

Source: Internet
Author: User


Install: libevent-2.0.13-stable.tar.gz memcached-1.4.7.tar.gz 2. first install libevent: # tar zxvf libevent-2.0.13-stable.tar.gz # cd libevent-2.0.13-stable #. /configure-prefix =/usr # make install 3. test whether the libevent is successfully installed: # ls-al/usr/lib | grep libevent is not bad, and it is installed. 4. install memcached and specify the installation location of libevent in installation: # cd/tmp # tar zxvf memcached-1.4.7.tar.gz # cd memcached-1.4.7 #. /configure-with-libevent =/usr # make install. After the installation is complete, put memcached in/usr/local/bin/memcached, 5. test whether memcached is successfully installed: # ls-al/usr/local/bin/mem * PHP extension for installing Memcache 1. on the http://pecl.php.net/package/memcache, select the memcache version you want to download. 2. install PHP 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 such a prompt: Installing shared extensions:/usr/local/php/lib/php/extensions/no-debug-non-zts-2007xxxx/4. put php. extension_dir = ". /"changed 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. basic settings of so 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. the pid-d option is to start a daemon process.-m is 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 and-l is the IP address of the server listening. If there are multiple IP addresses, I have specified the IP address 192.168.0.200 for the server, and-p is the port for setting the Memcache listening, I set port 12000 here, preferably port 1024 or above, and the-c option is the maximum number of concurrent connections running. The default value is 1024. I set port 256 here, Set according to the load on your server.-P is the pid file for saving Memcache. Here I am saving it in/tmp/memcached. pid, 2. to end the Memcache process, run: # kill 'cat/tmp/memcached. pid can also start multiple daemon processes, but the ports cannot be repeated. 3. restart apache and test the service httpd restart Memcache environment: run the following PHP file. If This is a test !, Indicates that the environment is successfully set up. Start to appreciate the charm of Memcache! <? Php $ mem = new Memcache; $ mem-> connect ("10.0.1.146", 11211); $ mem-> set ("key", "This is a test! ", 0, 60); $ val = $ mem-> get (" key "); echo $ val;?> Author huze104

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.