zoukankan      html  css  js  c++  java
  • linux下apache php配置redis

    1、安装redis

    第一步:

    下载:https://github.com/nicolasff/phpredis/archive/2.2.4.tar.gz
    
    上传phpredis-2.2.4.tar.gz到/usr/local/src目录
    
    cd /usr/local/src #进入软件包存放目录
    
    tar zxvf phpredis-2.2.4.tar.gz #解压
    
    cd phpredis-2.2.4 #进入安装目录
    
    /usr/local/php/bin/phpize #用phpize生成configure配置文件
    如果出现:
    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 is set correctly and then rerun this script.
     
    用下面的方法解决:
    # 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
    

    第二步:

    ./configure --with-php-config=/usr/local/php/bin/php-config  #配置
    
    make  #编译
    
    make install  #安装

    安装完成之后,出现下面的安装路径

    /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/

    第三步:

    vi /usr/local/php/etc/php.ini  #编辑配置文件,在最后一行添加以下内容

    添加

    extension="redis.so"
    
    :wq! #保存退出

    第四步:

    /usr/local/apache2/bin/apachectl restart
    

    第五步:

    #cd /usr/local/apache2/htdocs
    
    #touch redis.php
    
    #vi redis.php
    

      编辑php文件

    <?php
        ini_set('display_errors',1);
        error_reporting(E_ALL);
        $redis=new Redis();
        $redis->connect('127.0.0.1',6379);
        $redis->set('test','helloworld');
        echo $redis->get('test');
    ?>
    

      启动redis服务

    cd /usr/local/src/redis-3.0.6/src
    
    ./redis-server

    访问 IP/redis.php

    显示 

    helloworld

    参考: 

    http://www.cnblogs.com/zgaspnet/p/3939198.html

    http://www.cnblogs.com/jshen/archive/2013/07/05/3173729.html

  • 相关阅读:
    helloc
    传Intel镁光合资公司重启新加坡闪存芯片厂投产计划 月产能可达10万片
    关于c++ cout输出顺序问题。
    记录一次迁移Apollo Server V3的过程
    从springfox迁移到springdoc
    angular和spring boot的standalone部署
    随便总结几条委托和事件的知识点
    TCP连接的建立与断开
    开博第一天
    使用HTTP协议时判断客户端是否“在线”?
  • 原文地址:https://www.cnblogs.com/cxscode/p/7355387.html
Copyright © 2011-2022 走看看