Home > Backend Development > PHP Problem > How to install memcache extension in php

How to install memcache extension in php

藏色散人
Release: 2023-03-07 21:50:02
Original
1978 people have browsed it

How to install memcache extension in php: first download and decompress "memcache-2.2.7.tgz"; then compile by using phpize and php-config; then install by "make install"; finally modify php .ini is enough.

How to install memcache extension in php

Recommended: "PHP Video Tutorial"

The operating environment of this tutorial: Windows 7 system, PHP version 5.6, This method works for all brands of computers.

PHP 5.6.23, the most stable version currently is memcache-2.2.7.

#1. Download and unzip.

wget http://pecl.php.net/get/memcache-2.2.7.tgz

tar zxvf memcache-2.2.7.tgz

2. Compile. Use phpize and php-config according to the actual situation.

[root@www memcache-2.2.7]# /usr/local/php/bin/phpize
Configuring for:
PHP Api Version:     20131106
Zend Module Api No:   20131226
Zend Extension Api No:  220131226
Copy after login
[root@www memcache-2.2.7]# ./configure --enable-memcache --with-php-config=/usr/local/php/bin/php-config
Copy after login

3. Installation. make;make install

[root@www memcache-2.2.7]# make install
Installing shared extensions:   /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/
Copy after login

4. Modify php.ini (add extension=memcache.so) and restart php-fpm.

Let’s test the connectivity between php and memcache under Linux. Assume that the memcached server side is at 127.0.0.1. Generate the op_mem.php file, the code is as follows:

<?php
  $memcache = new Memcache;
  $memcache->connect(&#39;127.0.0.1&#39;,11211) or die("Could not connect Mc server");
  $memcache->set(&#39;key&#39;,&#39;oldboy book&#39;);
  $get= $memcache->get(&#39;key&#39;);
  echo $get;
?>
Copy after login

Execute the file and return the corresponding value:

[root@www bbs]# /usr/local/php/bin/php op_mem.php 
oldboy book
Copy after login

The above is the detailed content of How to install memcache extension in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template