一、安装libevent函数库

下载地址:http://libevent.org

默认被安装到:/usr/local/lib目录下

安装memcached之前需要先安装libevent函数库。

可以通过#ls -al /usr/local/lib | grep libevent命令查看是否已安装libevent函数库。

如果没安装,则需下载并安装libevent函数库。

二、安装memcached

下载地址:http://memcached.org

默认被安装到:/usr/local/bin目录下

安装完毕后,

先将libevent包路径加入/etc/ls.so.conf文件中

#vi /etc/ld.so.conf

在最后面一行加入/usr/local/lib

完成后输入以下命令启动memcached主程序

/usr/local/bin/memcached -d -m 1024  -u root -l 需要访问memcached的客户端ip地址 -p 11211 -c 1024 -P /tmp/memcached.pid

常用启动参数如下:

-m:最大使用内存,以MB为单位,默认64。

-p:进程所使用的TCP进程端口,默认11211。

-d:将memcached作为后台守护进程运行。

-u:启动用户。

-P:进程文件存放路径。

-c:最大运行并发数,默认1024。

-l:监听服务地址(即允许telnte登录的IP)。

如果出现以下报错:error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory

则说明memcached找不到libevent的位置,解决办法及原因如下:

原因之一:虽然刚刚我们在/etc/ls.so.conf文件里添加了libevent包目录,但系统还没有识别到这个新的动态链接库。

解决办法:我们需要执行一下ldconfig命令,这个命令通常在系统启动时运行,而当用户安装了一个新的动态链接库时,就需要手工运行这个命令。

这个命令的用途:默认搜寻/lilb和/usr/lib,以及配置文件/etc/ld.so.conf内所列的目录下的库文件。

启动完成后,可查看memcached主程序是否存在

#pstree | grep mem

三、安装memcache扩展

下载地址:http://pecl.php.net/package/memcache

memcache是php的一个扩展模块,安装前应先保证目前具备php环境。

先找到phpize的存在目录(如果是通过yum安装的php,则存在于/usr/bin中,如果没找到它们,则#yum install php-devel并重启)

解压memcache压缩包后,“进入解压出的文件夹中”。接下来使用phpzie将memcache编译到php扩展模块中。

#/usr/bin/phpize

#./configure --with-php-config=/usr/bin/php-config

(此时如果error: memcache support requires ZLIB报错,则说明没有zlib,可以yum一个,之后重启:#yum install -y zlib.x86_64 zlib-devel.x86_64)

检测成功后就可以用make编译memcache了:

#make

#make install

Installing shared extensions:     /usr/lib64/php/modules/

(上面的结果表示:扩展将被安装到/usr/lib64/php/modules/目录)

最后还需要修改php.ini配置项,过程如下:

#vim /etc/php.ini

(在700多行找到下面的命令,将注释去掉,有些没有也可手动添加)

extension_dir = "/usr/lib64/php/modules/"
extension = "memcache.so"
extension = "pdo_mysql.so"

重启服务器

可以用#telnet memcached所在服务器ip地址 11211

来查看是否可以连接memcached

之后可以通过phpinfo函数查看memcache的配置信息

linux安装memcached及memcache扩展的更多相关文章

  1. linux下给php安装memcached及memcache扩展(转)

    http://kimi.it/257.html (另外的方法)linux安装memcached及memcache扩展一.安装libevent函数库下载地址:http://libevent.org默认被 ...

  2. linux安装memcached和php的memcache扩展 (已使用)

    所需软件libevent-1.4.6-stable.tar.gz (http://monkey.org/~provos/libevent/)memcache-2.2.3.tgz (http://pec ...

  3. linux下php7安装memcached、redis扩展

    linux下php7安装memcached.redis扩展 1.php7安装Memcached扩展 比如说我现在使用了最新的 Ubuntu 16.04,虽然内置了 PHP 7 源,但 memcache ...

  4. linux centos 安装php的memcache扩展

    一.centos6.5 yum安装php的memcache扩展 搜索memcache yum search memcache 有了,现在可以安装了 yum -y install memcached m ...

  5. centos'的yum安装php的memcache扩展

    centos'的yum安装php的memcache扩展 博客分类: linux   让php能使用memcached服务的扩展有两种:memcache 和 memcached 1. 先安装libmem ...

  6. 安装php的memcache扩展

    linux: 安装环境 RHEL 4 Php 5.2.6 所需软件 libevent-1.4.6-stable.tar.gz (http://monkey.org/~provos/libevent/) ...

  7. ubuntu下安装memcached与php扩展测试使用

    1,memcached需要libevent,所以要先安装它 下载地址:http://download.chinaunix.net/download.php?id=45065&ResourceI ...

  8. 安装PHP及Memcache扩展

    安装PHP及Memcache扩展 地址:http://blog.csdn.net/poechant/article/details/6802312   1. 下载 (1)libevent 官方网页:h ...

  9. window下安装php7的memcache扩展

    安装memcache:http://www.runoob.com/memcached/memcached-connection.html1.4.4 c:\memcached\memcached.exe ...

随机推荐

  1. 如何安装Ecshop for linux

    下载 http://update.shopex.com.cn/version/program/ECShop/download_ecshop_utf8.php 解压缩之后把upload文件夹中的内容放到 ...

  2. popupwindow点击空白处如何自动消失?

    Popupwindow如果需要点击空白处自动消失,需要设置两个函数 1.customPopWindow.setFocusable(true);该函数也可以在构造函数中设置,如:mPopupWindow ...

  3. 用js完成毫秒格式数据的日期格式化任务

    后台传过来的数据  creationTime  在后台是Date类型的 毫秒转换成  05-24  月 日格式的 //获得月日得到日期oTime function getMoth(str){ var  ...

  4. Android 编程下 ListView 的 HeaderView 和 FooterView 不可选择点击

    在 ListView 里,HeaderView 和 FooterView 也占一行,与其他的 item 一样,可以点击,有索引,HeaderView 的索引为0.如果要使这两项不可点击,可以使用下面的 ...

  5. js 的一点用法

     js 中的json对象,ajax返回数据dataType为json否则无法将数据转换成json对象 也就无法通过json字符串转换成对象object,那么他将始终是个字符串,也就无法进行 对象操作. ...

  6. redis 的安装

    1: redis 是什么 Redis is an open source (BSD licensed), in-memory data structure store, used as databas ...

  7. AngularJS html+DOM+ng-click事件

    ng-disabled 指令直接绑定应用程序数据到 HTML 的 disabled 属性. ng-show 指令用于设置应用部分是否可见. ng-show="true" 设置 HT ...

  8. ASP.NET MVC中使用highcharts 生成简单的折线图

        直接上步骤:   生成一个options,选项包含了一些基本的配置,如标题,坐标刻度,serial等: 配置X轴显示的Category数据,为一个数组: 配置Y轴显示的数据,也为一个数据: 用 ...

  9. Bridge模式——对象结构型模式

    今天看了Bridge模式,对其进行简单的总结,并给出几篇通俗易懂的文章链接. (一)意图--将抽象部分和它的实现部分分离,使它们都可以独立地变化. 适用于从多维度描述的类型,拆解开来,使其能沿着各维度 ...

  10. struts.properties配置详解

    Struts 2框架有两个核心配置文件,其中struts.xml文件主要负责管理应用中的Action映射,以及该Action包含的Result定义等.除此之外,Struts 2框架还包含     st ...