Download Libevent, this is memcache support . From the Internet to find the source code directly compiled installation. Note: CentOS is installed by default so there is no need for this step. To test whether the libevent is installed successfully:
# Ls-al/usr/lib | grep libevent
lrwxrwxrwx 1 root root-17:38 libevent-1.2.so.1-libevent-1.2.so.1.0.3
-rwxr-xr-x 1 root root 263546 17:38 libevent-1.2.so.1.0.3
-rw-r–r–1 root root 454156 17:38 libevent.a
-rwxr-xr-x 1 root root 811 17:38 libevent.la
lrwxrwxrwx 1 root root-17:38 libevent.so-libevent-1.2.so.1.0.3
2. Download the installation Memcache (this is for the native installation of Memcache, if the PHP extension, can be slightly)
Download the latest version directly on Memcache's official website, then unzip the installation
# tar ZXVF memcached-1.*.*.tar.gz
# CD Memcached-1.*.*
The next step to note is that the directory where the Libevent is located may be different from the following, can be Whereis libevent to view the directory
#./configure--prefix=/usr/local/memchached--with-libevent=/usr/local/libevent
# Make;make Install
3. Installing the PHP memcache extension
http://pecl.php.net/get/memcache-2.2.7.tgz ( Of course you can also download other versions)
Unzip the directory and then go to the directory and execute
first Find out phpize (as for what to do their own search) location Whereis phpize, if not, execute the command yum install Php-devel, because Phpize is the devel of PHP.
Executive Phpize
Pre-compilation configuration after execution
./configure--enable-memcache--with-php-config=/usr/bin/php-config --with-zlib-dir
(also here you need to find out where the Scarlet Letter part is located)
Make
Make install
You will then be prompted
After installation, there will be a hint like this:
Installing Shared extensions:/usr/lib/php/modules/
Keep this in mind and then modify the php.ini to put
Extension_dir = "./"
Revision changed to
Extension_dir = "/usr/lib/php/modules/"
and add a row
Extension=memcache.so
——————————————————————————
To this basic is done, and then we start memcache,
memcache-uroot-p21003-m1024 (if this is done directly then the window will not be able to exit and will need to be run as a daemon)
——————————————————————————————————
Write a PHP script below
<?php $memcache = new Memcache; Create a Memcache object $memcache->connect (' localhost ', 11211) or Die ("Could not Connect"); Connect the memcached server $memcache->set (' key ', ' test '); Set a variable into memory, the name is the key value is Test $get _value = $memcache->get (' key '); Remove the value of key from memory echo $get _value;? >
——————————————————————————
And then the problem that may arise here is Failed reading line from stream (0)
This problem may be caused by 1. The memory is not enough, you set the memory is too big, crashed 2. You're not performing as a daemon, and maybe the backstage memcache is closed.
PS Aux|grep memcached
Yum Install PHP installation memcache Expand the entire introduction