Method 1
Install libmemcached first. Skip this step if it is already installed.
Directly configure prompts that the memcached binary file cannot be found. It has already been installed. Well, make it.
The code is as follows: |
Copy code |
./Configure -- with-memcached =/usr/local/platform/memcached/bin/memcached |
OK. The compilation is successful. make & make install. OK is also installed. OK
Go to the memcached for php Directory
The code is as follows: |
Copy code |
Cd/download/memcached-2.0.1 /Usr/local/platform/php5.4.2/bin/phpize ./Configure -- with-php-config =/usr/local/platform/php5.4.2/bin/php-config Make & make install |
Vi/etc/php. ini
Add at the bottom:
The code is as follows: |
Copy code |
[Memcached] Extension = memcached. so |
Add memcached without re-compiling php
After the php installation is complete, some extensions are not found in the application. This is a high probability in the application process! Below is a simple record of the process of installing the memcached extension!
The process of installing the extension is as follows:
Note: this extension requires the & raquo; libmemcached client library.
The code is as follows: |
Copy code |
# Tar-zxvf libmemcached-1.0.2.tar.tar # Cd libmemcached-1.0.2 #./Configure # Make & amp; make install # Ldconfig-p | grep libmem # Tar-xf memcached-2.0.0b2.tgz # Cd memcached-2.0.0b2 #/Usr/local/php/bin/phpize #./Configure # Make & amp; make install # Cd modules // * copy memcached. so to the extension directory, which can be found in php. ini */ # Cd/usr/local/php/lib/php/extend/no-debug-non-zts-20090626/ # Vim/usr/local/php/etc/php. ini/* Add extension = "memcached. so "*/ # Service php-fpm restart/* restart the php-fpm process */ /* Verify whether the extension is available */ |
Test Code
The code is as follows: |
Copy code |
<? Php $ M = new Memcached (); $ M-> addServer ('127. 0.0.1 ', 127 ); $ M-& gt; setOption (Memcached: OPT_COMPRESSION, false ); $ M-& gt; set ('foo', 'ABC '); $ M-& gt; append ('foo', 'Def '); Var_dump ($ m-& gt; get ('Foo ')); |
Summary:
1. Download related package files [we recommend that you refer to the download location in the php Manual to download related extensions];
2. Install the service package and start the service;
3. Use phpize in the php extension package and re-compile the extension package to package the extension into A. so file [in the current folder by default];
4. View php. ini file, find the php extension directory to generate the above. copy the so file to the extension directory. add, modify, and restart php in ini extension. View phpinfo and you will find the corresponding extension;
5. memcache and memcached extensions [create a. so file after installation, provide php extension] use the same service memcached [start default port: 11211]