Install Memcache to CentOS (Attach Yum method)

Source: Internet
Author: User
Tags curl install php memcached zts

Install Memcache to CentOS (Attach Yum method)

A method of installing Memcache on CentOS is reproduced.

All operations are logged in under SSH with the root account.

My version is CentOS Release 5.3 (Final)
Use this command to know your Linux version
Cat/etc/redhat-release
First, you install the Libevent library.
Cd/usr/local/src
Curl-o http://monkey.org/~provos/libevent-1.4.10-stable.tar.gz
Tar xzvf libevent-1.4.10-stable.tar.gz
CD libevent-1.4.10-stable
./configure–prefix=/usr/local
Make
Make install

The next step is to install memcached

Cd/usr/local/src
Curl-o http://www.danga.com/memcached/dist/memcached-1.2.8.tar.gz
Tar xzvf memcached-1.2.8.tar.gz
CD memcached-1.2.8
Ldflags= '-wl,–rpath/usr/local/lib './configure–prefix=/usr/local
Make
Make install

After installation, use the following command to run memcache with user root
Memcached-u root-d-M 64-l 192.168.0.101-p 11211
Root is the user that is being executed
64 for Cache Size 64M
192.168.0.101 is the server IP address
11211 is the port where

To close Memcache
Pkill memcached

The next step is to install Php-pecl-memcache
One command is OK.
Yum Install Php-pecl-memcache

Still need PHP extensions, use the following command
PECL Install Memcache

Next restart Apache, with phpinfo () view, you should see the Memcache section, if not, check the settings here:
/etc/php.ini plus extension=memcache.so.
Of course, also want to confirm whether memcache.so exist, whether under/usr/lib/php/modules/, if not, then find it, and the full path to represent.

To see how the Memcache is running, you can use memcache.php to view it.
When you want to have the Web program support is useful, such as I use the phpBB 3 can use Memcache, specific methods for reference here

Original Author: David Yin

Update

But I did not use the above method in actual combat today:

Introduce the Yum method:

Yum Installlibevent

This is the first step,

The second step is to install memcache, but the standard CentOS5 software warehouse is not memcache the corresponding package, so our first step is to import Third-party software Warehouse, here is recommended Dag Wieers library (now called Rpmforge), the installation method is as follows:

wget http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm

RPM-IVH rpmforge-release-0.3.6-1.el5.rf.i386.rpm

Find related Packages

Yum Search Memcache

Now that you have it, you can install it.

Yum-y Install–enablerepo=rpmforge memcached Php-pecl-memcache

Verify the installation results

Memcached-h

Php-m|grep Memcache

Start memcached

/sbin/servive memcached Start

============

Update Dec 16th

Linux memcache server-side installation
Server side is mainly installed Memcache server side, the latest version is memcached-1.3.0.
Download: http://www.danga.com/memcached/dist/memcached-1.2.2.tar.gz
In addition, Memcache used libevent This library for socket processing, so also need to install the latest version of Libevent,libevent is libevent-1.3. (If your system has libevent installed, you may not need to 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 to specify an installation path, i.e../configure–prefix=/usr; then make; then make install;
2. Reinstall the memcached, just need to specify the Libevent installation path in the configuration, that is./configure–with-libevent=/usr; then make; then make install;
This completes the Linux Memcache server-side installation. The detailed approach is 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
It's all right, it's all set up.

4. Install memcached, also need to install the designated Libevent installation location:
# 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 check the errors carefully, and configure or add the corresponding libraries or paths according to the error message.
When the installation is complete, the memcached will be placed in the/usr/local/bin/memcached,

5. Test for successful installation of memcached:
# 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 Memcache PHP Extensions
1. Select the Memcache version that you want to download in Http://pecl.php.net/package/memcache.
2. Install the PHP memcache extension

Tar vxzfmemcache-2.2.1.tgz
CD memcache-2.2.1
/usr/bin/phpize
./configure-enable-memcache-with-php-config=/usr/bin/php-config-with-zlib-dir
Make
Make install

3. The above installation will have a similar hint:

Installing sharedextensions:/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 Memcache server side:
#/usr/local/bin/memcached-d-M 10-u root-l 66.90.103.147-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 am 10MB here,
-U is the user running memcache, I am here root,
-L is a listening server IP address, if there are more than one address, I specify the IP address of the server 192.168.0.200,
-P is the port that sets the memcache listening, I set 12000 here, preferably 1024 or more ports,
The-c option is the maximum number of concurrent connections to run, the default is 1024, I set 256 here, according to the load of your server to set,
-P is set to save the Memcache pid file, which 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 Environment test:
Run the following PHP file, if the output is a test!, it means that the environment has been built successfully. began to appreciate the charm of memcache.
< PHP
$mem = new Memcache;
$mem->connect ("66.90.103.147″, 12000");
$mem->set (' key ', ' This is a test! ', 0, 60);
$val = $mem->get (' key ');
Echo $val;
?>

Related Article

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.