Rumah  >  Artikel  >  pembangunan bahagian belakang  >  php5.5怎么安装memcache扩展

php5.5怎么安装memcache扩展

王林
王林asal
2021-02-22 14:38:041500semak imbas

php5.5安装memcache扩展的方法:1、下载并解压缩memcache扩展;2、使用phpize命令编译;3、使用make命令安装;4、编辑php.ini配置文件,并重启php-fpm。

php5.5怎么安装memcache扩展

本文操作环境:red hat enterprise linux 7.4系统、php 5.5、thinkpad t480电脑。

具体步骤:

1、下载并解压缩。

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

2、编译。根据实际情况使用phpize和php-config。

[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
[root@www memcache-2.2.7]# ./configure --enable-memcache --with-php-config=/usr/local/php/bin/php-config

3、安装。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/

4、修改php.ini(添加 extension=memcache.so)并重启php-fpm。

d0834ff3d092d8dcc8d4a58e3fa3ec4.png

下面在linux下测试一下php与memcache的连接性。假设memcached服务器侧就在127.0.0.1。生成op_mem.php文件,代码如下:

<?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;
?>

执行该文件,返回相应取值:

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

相关推荐:php教程

Atas ialah kandungan terperinci php5.5怎么安装memcache扩展. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!

Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Artikel sebelumnya:php怎么关闭debug模式Artikel seterusnya:php怎么去除非法字符