Linux under Memcache server-side installation _php Tutorial

Source: Internet
Author: User
Tags zts
Linux under Memcache server-side installation
Server side is mainly installed Memcache server side, the current version is memcached-1.3.0.
Download: http://www.danga.com/memcached/dist/memcached-1.2.2.tar.gz
In addition, Memcache used the libevent this library for socket processing, so you also need to install the latest version of Libevent,libevent is libevent-1.3. (If your system already has libevent installed, you can not 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 with an installation path, i.e../configure–prefix=/usr; then make; then make install;
2. Install the memcached again, just need to specify the installation path of libevent when configuring the./configure–with-libevent=/usr; then make; then make install;
This completes the installation of Linux under the Memcache server side. The detailed methods are 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

(Note: There is an error when executing here:

1,no acceptable C compiler found in $path

Because CentOS does not have GCC installed by default, use Yum to install

#yum Install gcc* make*

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

Good, all installed.

4. Install the memcached and require the installation location of the specified 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 there is an error in the middle, please carefully check the errors, follow the error message to configure or add the appropriate library or path.

(Note: An error occurred during installation:

1 Linux Warning: A clock error has been detected. Your creation may not be complete

Workaround:

Modify the current time:

[Root] #date –s ' 2010/11/5 8:01:00 '

Writes the current system time to the CMOS
#clock –w

)
When the installation is complete, the memcached will be put into/usr/local/bin/memcached,

5. Test whether the memcached is installed successfully:

# 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 the PHP tutorial extension for Memcache
1. Select the Memcache version you want to download in the Http://pecl.php.net/package/memcache.
2. Installing the PHP memcache extension

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

Note

1 phpize not found

Workaround:

CentOS is not installed by default Php-devel

Yum Install Php-devel

2 Make: * * * [Memcache.lo] Error 1

No zlib installed

Yum Install Zlib-devel

3 The configured command is changed to:./configure--enable-memcache--with-php-config=/usr/bin/php-config--with-zlib-dir

Where enable and with front is two--

3. There will be a hint like this after the installation is complete:

Installing Shared extensions:/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 server side of the memcache:
#/usr/local/bin/memcached-d-M 10-u root-l 192.168.0.200-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'm 10MB,
-U is the user running memcache, I am root here,
-L is the server IP address of the listener, if there are multiple addresses, I specify the server IP address 192.168.0.200,
-P is the port that sets Memcache listening, I set here 12000, preferably more than 1024 ports,
The-c option is the maximum number of concurrent connections to run, the default is 1024, I set the 256 here, according to the load of your server to set,
-P is set to save memcache PID file, I am here to save in/tmp/memcached.pid,

Note

1

Error occurred:/usr/local/bin/memcached:error while loading shared libraries:libevent-1.3.so.1:cannot open Shared object File:no Such file or directory

Direct Settings link

#ln-S/usr/local/libevent/lib/libevent-1.3.so.1/lib64/libevent-1.3.so.1

)

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 Environmental Testing:
Run the following PHP file, if there is output this is a test!, it indicates that the environment was built successfully. Begin to appreciate the charm of memcache!

< PHP
$mem = new Memcache;
$mem->connect ("192.168.0.200", 12000);
$mem->set (' key ', ' This is a test! ', 0, 60);
$val = $mem->get (' key ');
Echo $val;
?>

http://www.bkjia.com/PHPjc/444780.html www.bkjia.com true http://www.bkjia.com/PHPjc/444780.html techarticle Linux under the Memcache server side of the installation server is mainly installed Memcache server side, the current version is memcached-1.3.0. Download: http://www.danga.com/memcached/dist/me

  • 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.