在项目开发的时候有用到memcache,自己在本地需要搭建一个memcache环境,用于开发和测试;

wget http://www.memcached.org/files/memcached-1.5.10.tar.gz

tar zxvf memcached-1.5.10.tar.gz

./configure --prefix=/usr/local/libevent

make && make install

./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent

https://blog.csdn.net/happyrabbit456/article/details/44680597

https://blog.csdn.net/21aspnet/article/details/6827316

http://pecl.php.net/package/memcache

https://launchpad.net/libmemcached/+download

https://blog.csdn.net/u011547570/article/details/78325556

1.memcache服务器端的安装

学习源头:https://blog.csdn.net/21aspnet/article/details/6827316

服务器端主要是安装memcache服务器端,目前的最新版本是 memcached-1.5.10

官网地址:http://memcached.org/

这是官方给的安装方法:可以参考一下

Debian/Ubuntu: apt-get install libevent-dev Redhat/Centos: yum install libevent-devel

wget http://memcached.org/latest
tar -zxvf memcached-1.x.x.tar.gz
cd memcached-1.x.x
./configure && make && make test && sudo make install

但是在安装memcache的时候,需要先安装libevent

1.先安装libevent

官网地址:http://libevent.org/

先去下载压缩包:

wget https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz

tar zxvf libevent-2.1.8-stable.tar.gz

cd libevent-2.1.8-stable

./configure --prefix=/usr/local/libevent

make && make install

2.安装memcache

官网地址:http://memcached.org/

先去下载压缩包:

wget http://www.memcached.org/files/memcached-1.5.10.tar.gz

tar -zxvf memcached-1.5.10.tar.gz

cd memcached-1.5.10

./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent

make && make install

如果中间出现报错,请仔细检查错误信息,按照错误信息来配置或者增加相应的库或者路径。
安装完成后会把memcached放到 /usr/local/bin/memcached ,

测试是否成功安装memcached:
ps -ef |grep memcached

或者pgrep memcached

2.php memcache扩展的安装

学习源头:https://blog.csdn.net/u011547570/article/details/78325556

pecl官方网站:http://pecl.php.net/package/memcache

由于好像memcache很久没有更新了,不支持php7(没有实测)

在安装memcache的时候,就直接去github上找的代码

https://github.com/php-memcached-dev/php-memcached

php7分支的(我们要的) https://github.com/php-memcached-dev/php-memcached/tree/php7

下载下来以后 进入目录

/usr/local/php-fpm/bin/phpize

./configure –with-php-config=/usr/local/php-fpm/bin/php-config

make && make install

可以看到 memcached 已经安装完成,并且扩展文件已经放到提示的目录:

[root@lnmp memcached]# ls /usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/
memcached.so  opcache.a  opcache.so
[root@lnmp memcached]#

最后一步在 php.ini 中引入 memcached.so

[root@lnmp memcached]# vim /usr/local/php7/lib/php.ini

加入:

extension=memcached.so

记得 reload 一下 php-fpm 才能生效

[root@lnmp memcached]# systemctl reload php-fpm

打开 phpinfo 页面,已经已经看到 memcached 扩展成功安装了。

3.安装memcached

1.在安装memcached扩展的时候,需依赖于libmemcached

官方网站:https://launchpad.net/libmemcached/+download

这个是新版的客户端基于libmemcached,所以必须要安装libmemcached
先安装libmemcached

wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz

tar zxvf libmemcached-1.0.18.tar.gz

cd libmemcached-1.0.18

./configure --prefix=/usr/local/libmemcached/ --with-libmemcached-dir=/usr/local/libmemcached/

make && make install

2.memcached客户端

尝试用 PECL 安装,memcached 在 PECL 上的地址是:
https://pecl.php.net/package/memcached

[root@lnmp lnmp.cn]# pecl install memcached
pecl/memcached requires PHP (version >= 5.2.0, version <= 6.0.0, excluded versions: 6.0.0), installed version is 7.0.8
No valid packages found
install failed
[root@localhost vagrant]#

提示很明显,PECL 上的 memcached 扩展只支持 PHP 5.2 以上,6.00 以下的版本。还未更新到 PHP7。不过还好的是在 PECL 的 memcached 页面可以找到他们在 github 上的链接:
https://github.com/php-memcached-dev/php-memcached
这上面的代码已经有可以支持到 PHP7 的分支。这里将源码统一下载到 php 源码的 ext 目录:

wget https://github.com/php-memcached-dev/php-memcached.git

进入主目录

/usr/local/php-fpm/bin/phpize

./configure --with-php-config=/usr/local/php/bin/php-config --with-libmemcached-dir=/usr/local/libmemcached/

make && make install

修改php.ini添加extension = "memcached.so"就可以

4.检测是否安装成功呢?

要重启php

关闭php-fpm

ps -ef|gerp php-fpm

killall php-fpm

/usr/local/php-fpm/sbin/php-fpm

然后再试一下 应该就可以了

php -m 查看

是否有安装扩展

lnmp centos7 memcache服务器端 和 memcache memcached扩展的安装的更多相关文章

  1. PHP memcached 扩展的安装

    PHP memcached 扩展的安装 1.下载相关的源码包(软件版本自己选择) memcached-1.4.15 , http://memcached.org/ //Memcached服务端. me ...

  2. PHP7 下安装 memcache 和 memcached 扩展

    转载自:https://www.jianshu.com/p/c06051207f6e Memcached 是高性能的分布式内存缓存服务器,而PHP memcache 和 memcached 都是 Me ...

  3. [转]编译安装libevent,memcache,以及php的memcached扩展

    一 安装libevent 1.去官网http://libevent.org/ 下载最新源码,我用的是libevent-2.0.20-stable.tar.gz 2.解压到/usr/src目录 ,执行命 ...

  4. linux-CentOS6.4安装Memcached+memcached扩展+安装memcache扩展+Memcache+mecached同步SESSION的几种方法

    一.编译环境的准备 yum install gcc  yum install gcc-c++ libstdc++-devel  yum install zlib-devel 二.源代码包准备 wget ...

  5. CenOS下安装Memcache和PHP Memcache扩展.

    I.安装Memcahce 1. 安装依赖包libevent Memcache需要安装libevent,所以安装前可能需要执行 yum install libevent-devel 2.安装memcac ...

  6. CentOS 6.6 安装 PHP Memcached 扩展

    PHP 的 Memcached扩展使用了 libmemcached 库提供的 api 与 memcached 服务端进行交互.它同样提供了一个 session 处理器(memcached). PHP ...

  7. 安装PHP memcached扩展

    引用 pecl.php.net有两个memcache扩展: memcache   memcached extension memcached PHP extension for interfacing ...

  8. centos6下安装php7的memcached扩展

    安装php7的memcached扩展 .编译安装libmemcached- wget https://launchpadlibrarian.net/165454254/libmemcached-1.0 ...

  9. Memcache服务器端+Redis服务器端+PHP Memcache扩展+PHP Memcached扩展+PHP Redis扩展+MemAdmin Memcache管理工具+一些概念(更新中)

    Memcache和Redis因为操作简单,是我们常用的服务器数据缓存系统,以下文字仅作备忘记录,部份转载至网络. 一.定义 1.Memcache Memcache是一个高性能的分布式的内存对象缓存系统 ...

随机推荐

  1. CommStringLib

    #include "syswatcher/CommStringLib.h" //#include "String16.h" #undef LOG_TAG #de ...

  2. 大家来聊聊如何PASS 360

    真正做到PASS 360,启动项什么的.我觉得还是有可能的把? 虽然它就是一个流氓,但是我们要想办法比它更流氓. 只是有一个点:那就是行为监控,那既然行为监控(云分析抛开).那就找一个可信任的程序来调 ...

  3. 因磁盘爆满而导致NameNode HA无法启动

    场景回顾: 测试集群节点分配:35,36是namenode且开启HA,37,38,39即作为datanode,又作为journalnode. 某时间 38节点磁盘爆满,集群中hdfs及依赖的服务全部宕 ...

  4. Linux 实用指令之查看端口开启情况

    netstat -ntlp 查看端口使用情况! netstat -ntlp | grep 80 查看具体的端口是否使用! # netstat -ntlp Active Internet connect ...

  5. angularjs分页组件

    这是我第一次写博客,激动,首先,我也是个菜鸟,分享一下自己写的服务器端分页的代码,自己一步一步写的,其中也有参考别人的代码.技术比较渣,先这样了. // ====== 2019-1-3 ======/ ...

  6. 源码安装LNMP与搭建Zabbix

    系统环境:CentOS release 6.5 (Final) 搭建Zabbix 3.0对PHP环境要求>= 5.4 一.下载NMP的软件包: N:wget http://nginx.org/d ...

  7. POJ3275:Ranking the Cows(Bitset加速floyd求闭包传递)

    Each of Farmer John's N cows (1 ≤ N ≤ 1,000) produces milk at a different positive rate, and FJ woul ...

  8. python学习笔记(datetime、字符串转换)

    datetime对象与字符串可以互相转化 代码如下: from datetime import datetime def datetime_string(time): return time.strf ...

  9. Python SQL相关操作

    环境 Anaconda3 Python 3.6, Window 64bit 目的 从MySQL数据库读取数据,进行数据查询.关联 代码 # -*- coding: utf-8 -*- "&q ...

  10. python fire库的使用

    一. 介绍 fire是python中用于生成命令行界面(Command Line Interfaces, CLIs)的工具,不需要做任何额外的工作,只需要从主模块中调用fire.Fire(),它会自动 ...