zoukankan      html  css  js  c++  java
  • linux上安装php7 memcache扩展 和 安装服务端memcached

    转:https://www.cnblogs.com/hejun695/p/5369610.html

    先说安装服务端 memcached

    1. 首先安装Libevent事件触发管理器。

    wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
    tar vxf libevent-2.0.21-stable.tar.gz
    cd libevent-2.0.21-stable
    ./configure -prefix=/usr/local/libevent    # ./configure
    make && make install

    2. 编译安装memcached

    复制代码
    wget http://memcached.org/latest
    cp latest memcached.tar.gz
    tar -zxvf memcached.tar.gz
    cd memcached
    ./configure -with-libevent=/usr/local/libevent   # ./configure
    make && make install
    复制代码

    3. 启动memcached

    /usr/local/memcached/bin/memcached -d -m 128 -l 127.0.0.1 -p 11211 -u root   # (128为内存, 11211为端口,root为用户组)

    4. 开机/重启后生效,编辑 /etc/rc.d/rc.local 文件,添加以下内容。

    /usr/local/memcached/bin/memcached -d -m 128 -l 127.0.0.1 -p 11211 -u root

    5. 查看是否启动成功

    ps aux|grep memcached

    如图则成功

    -----------------------------------------------------------------------分割线-----------------------------------------------------------------------------------

    下面则是php的扩展memcache安装了。

    用之前的php版本安装是没有问题,但是用了php7安装 http://pecl.php.net/package/memcache 下的任一款memcache都会报错

    穷尽一切办法之后发现了 Github的pecl-memcache分支版本

    本地下载,https://github.com/websupport-sk/pecl-memcache/archive/php7.zip

    1. rz命令 上传至linux虚拟机上。

    unzip pecl-memcache-php7.zip
    cd pecl-memcache-php7
    /usr/local/php/bin/phpize //可能报错,看下面解决方法
    ./configure --with-php-config=/usr/local/php/bin/php-config
    make && make install

    ps:

    运行/usr/local/webserver/php/bin/phpize时出现:
    Configuring for:
    PHP Api Version:         20041225
    Zend Module Api No:      20060613
    Zend Extension Api No:   220060519
    Cannot find autoconf. Please check your autoconf installation and the
    $PHP_AUTOCONF environment variable. Then, rerun this script.
    根据网上的解决办法是:
    
    # cd /usr/src
    # wget http://ftp.gnu.org/gnu/m4/m4-1.4.9.tar.gz
    # tar -zvxf m4-1.4.9.tar.gz
    # cd m4-1.4.9/
    # ./configure && make && make install
    # cd ../
    # wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.62.tar.gz
    # tar -zvxf autoconf-2.62.tar.gz
    # cd autoconf-2.62/
    # ./configure && make && make install
    可爱的yum让我更容易把没安装的包安装好
     yum install m4
     yum install autoconf

    2. 修改php.ini 加载Memcache组件

    [memcache]
    extension_dir = "/usr/local/php70/lib/php/extensions/no-debug-non-zts-20151012/"
    extension = "memcache.so"

    注!!!一定要确认有效的 php.ini的位置 

    查找php.ini位置的方法

    1.写一个测试文件,内容<?php phpinfo(); ?>,在第七八行左右,有“Loaded Configuration File”就标明了php.ini的位置。
    2.没指定php.ini或者找不到php.ini(none),php会按照默认配置运行的。

    下面介绍一下memcached扩展的安装方式,其实PHP的扩展安装方式非常类似

    1.  
      #首先需要安装libmemcached库
    2.  
      yum -y install libmemcached libmemcached-devel
    3.  
      #下载memcached扩展
    4.  
      wget https://github.com/php-memcached-dev/php-memcached/archive/php7.zip
    5.  
      #解压
    6.  
      unzip php7.zip
    7.  
      cd php-memcached-php7/
    8.  
      /usr/local/php/bin/phpize
    9.  
      #配置
    10.  
      ./configure --with-php-config=/usr/local/php/bin/php-config
    11.  
      make
    12.  
      make install

    在php.ini中添加memcached扩展

    extension=memcached.so
  • 相关阅读:
    寻找——无限游戏破关(一)
    运维入职梳理文档
    seafile 旧版本升级新版本时python库引用报错
    操作系统-计算进程的物理地址(例题)
    拉取微信公众号视频文件
    洛谷-P3654 First Step (ファーストステップ)
    洛谷-P3392 涂国旗
    洛谷-P1706 全排列问题
    洛谷-P1157 组合的输出
    洛谷-P2241 统计方形(数据加强版)
  • 原文地址:https://www.cnblogs.com/chancy/p/10408188.html
Copyright © 2011-2022 走看看