Install php memcache extension and phpmemcache Extension
Linux:
Installation environment
RHEL 4
Php 5.2.6
Required Software
Libevent-1.4.6-stable.tar.gz (http://monkey.org /~ Provos/libevent /)
Memcache-2.2.3.tgz (http://pecl.php.net/package/memcache)
Memcached-1.2.6.tar.gz (http://www.danga.com/memcached)
Install configurations
1. Install libevent
# Tar zxf libevent-1.4.6-stable.tar.gz
# Cd libevent-1.4.6-stable
#./Configure -- prefix =/usr/local/servers/libevent
# Make & make install
2. Install memcached
# Tar zxvf memcached-1.2.6.tar.gz
# Cd memcached-1.2.6
#./Configure -- prefix =/usr/local/servers/memcached -- with-libevent =/usr/local/servers/libevent
# Make & make install
3. Run memcached
#/Usr/local/servers/memcached-d-m 128-l localhost-p 11211-u root
-D run memcached in daemon mode;
-M: Set the memory size available for memcached, in MB;
-L set the IP address of the listener. If it is a local machine, this parameter is usually not set;
-P: Set the listening port. The default value is 11211. Therefore, you can leave this parameter unspecified;
-U indicates the user;
If you encounter problems when running memcached, the error prompt is as follows:
/Usr/local/servers/memcached/bin/memcached: error while loading shared libraries: libevent-1.4.so.2: cannot open shared object file: No such file or directory
Run LD_DUBUG = libs to know the library loading path when memcached is started. The details are as follows:
# LD_DEBUG = libs/usr/local/servers/memcached/bin/memcached-v
10929: find library = libevent-1.4.so.2 [0]; searching
10929: search cache =/etc/ld. so. cache
10929: search path =/lib/tls/i686/sse2:/lib/tls/i686:/lib/tls/sse2:/lib/tls:/lib/i686/sse2: /lib/i686:/lib/sse2:/lib:/usr/lib/tls/i686/sse2:/usr/lib/tls/i686: /usr/lib/tls/sse2:/usr/lib/tls:/usr/lib/i686/sse2:/usr/lib/i686:/usr/lib/sse2: /usr/lib (system search path)
10929: trying file =/lib/tls/i686/sse2/libevent-1.4.so.2
10929: trying file =/lib/tls/i686/libevent-1.4.so.2
10929: trying file =/lib/tls/sse2/libevent-1.4.so.2
10929: trying file =/lib/tls/libevent-1.4.so.2
10929: trying file =/lib/i686/sse2/libevent-1.4.so.2
10929: trying file =/lib/i686/libevent-1.4.so.2
10929: trying file =/lib/sse2/libevent-1.4.so.2
10929: trying file =/lib/libevent-1.4.so.2
10929: trying file =/usr/lib/tls/i686/sse2/libevent-1.4.so.2
10929: trying file =/usr/lib/tls/i686/libevent-1.4.so.2
10929: trying file =/usr/lib/tls/sse2/libevent-1.4.so.2
10929: trying file =/usr/lib/tls/libevent-1.4.so.2
10929: trying file =/usr/lib/i686/sse2/libevent-1.4.so.2
10929: trying file =/usr/lib/i686/libevent-1.4.so.2
10929: trying file =/usr/lib/sse2/libevent-1.4.so.2
10929: trying file =/usr/lib/libevent-1.4.so.2
10929:
Then create a link for the libevent-1.4.so.2 and then run memcached:
# Ln-s/usr/local/servers/libevent/lib/libevent-1.4.so.2/lib/libevent-1.4.so.2
4. Install the memcache extension of php
You can use the pecl installation program that comes with php.
#/Usr/local/servers/php5/bin/pecl install memcache
You can also install it from the source code.
# Tar zxf memcache-2.2.3.tgz
# Cd memcache-2.2.3
#/Usr/local/servers/php5/bin/phpize
#. /Configure -- enable-memcache =/usr/local/servers/memcached -- with-php-config =/usr/local/servers/php5/bin/php-config -- with-apxs2 =/ usr/sbin/apxs
# Make & make inst
After the installation is complete, a message like this will be prompted:
Installing shared extensions:/usr/local/servers/php5/lib/php/extension/ no-debug-non-zts-20060922/
Remember this, modify php. ini, and
Extension_dir = "./"
Change
Extension_dir = "/usr/local/servers/php5/lib/php/extensions /"
Add a row
Extension = "no-debug-non-zts-20060922/memcache. so"
5. Use phpinfo to view
Windows:
Download the stable version of memcache for windows and decompress it to a disk, for example, in d: \ memcached
2. Enter d: \ memcached \ memcached.exe-d install on the terminal (that is, the cmd command interface) to install
3. Enter c: \ memcached \ memcached.exe-d start to start.
NOTE: in the future, memcached will be used as a windows Service and will be automatically started every time it is started. In this way, the server has been installed.
4. Download php_memcache.dll. Find the corresponding php version file by yourself.
5. Add a line of extension = php_memcache.dll to php. ini.
6. Restart Apache and check phpinfo. If memcache exists, the installation is successful!
Test Module
<? Php
$ Memcache = new Memcache;
$ Memcache-> connect ('localhost', 12000) or die ("cocould not connect ");
$ Version = $ memcache-> getVersion ();
Echo "Server's version:". $ version. "<br/> \ n ";
$ Tmp_object = new stdClass;
$ Tmp_object-> str_attr = 'test ';
$ Tmp_object-> int_attr = 123;
$ Memcache-> set ('key', $ tmp_object, false, 10) or die ("Failed to save data at the server ");
Echo "Store data in the cache (data will expire in 10 seconds) <br/> \ n ";
$ Get_result = $ memcache-> get ('key ');
Echo "Data from the cache: <br/> \ n ";
Var_dump ($ get_result );
?>
Display result:
Server's version: 1.4.4-14-g9c660c0
Store data in the cache (data will expire in 10 seconds)
Data from the cache:
Object (stdClass) [3] public 'str _ attr '=> string 'test' (length = 4) public 'int _ attr' => int 123
----------------
The server side is memcached, and the client side can be considered as php_memcache.dll.
Php_memcache.dll provides a set of functions for caching, extraction, and deletion of cache operations. Through these functions, the data is stored on the machine where the memcached service is installed, it can be a local machine or a machine on other networks.
Memadmin is a powerful tool for viewing memcached servers. (Written in php + jquery)
2cto accessories: http://up.2cto.com/2011/1124/20111124050347851.rar
Baidu Network Disk download: http://pan.baidu.com/s/14HGPS
In the LAMP environment of CentOS56, how does one install the php memcache extension package?
1. Select the memcache version you want to download from pecl.php.net/package/memcache.
2. Install memcache extension for PHP
# Tar vxzf memcache-2.2.6.tgz
# Cd memcache-2.2.6
#/Usr/local/php/bin/phpize
#./Configure -- enable-memcache -- with-php-config =/usr/local/php/bin/php-config -- with-zlib-dir
# Make
# Make install
After the installation, a memcache. so will be generated in/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613 /.
Next, modify php. ini.
Extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626"
Extension = memcache. so
Save after modification
Restart the httpd service and test phpinfo () to see if there are any memcache items. If yes, the configuration is complete.
In Windows, how does PHP install the memcache extension module?
I did, but I didn't try .....
Let me give you a way. The current computer spends about 300 of the speed like a sports car. You should not mind following a virtual machine.
Sun's virtual machine will be quite useful. Install a LINUX system and contact us at will. If you are engaged in PHP, you will have to contact us sooner or later.