• 在centos7中为php7安装redis扩展


    在此之前一直是用php5.6,安装redis也没遇到啥问题,嗖嗖的就安装上了

    更新php版本到php7后,编译的时候报错

    include <ext/standard/php_smart_str.h>

    #make: *** [redis.lo] 错误 

    网上查资料,终于得到解决

    为php7安装redis步骤:

    首先我进入了/usr/local目录

    #使用git clone下载git上的phpredis扩展包

    [root@localhost local ]#git clone  https://github.com/phpredis/phpredis.git

     //具体用哪个要取决于你的phpize文件所在的目录,这时你应该用 whereis phpize 来查看路径

    [root@localhost local ]# whereis phpize

    phpize: /usr/bin/phpize /usr/share/man/man1/phpize.1.gz

     知道phpize之后呐,我们就开始处理了

    然后我进入了/usr/local/phpredis目录

    cd phpredis/

    [root@localhost phpredis ]# /usr/bin/phpize
    Can't find PHP headers in /usr/include/php
    The php-devel package is required for use of this command.

    这里报错了,原因是没有安装好php-devel,由于我是使用的php7.2所以执行以下命令:

     [root@localhost phpredis]#yum -y install php72w-devel

    然后再次执行:

    [root@localhost phpredis]# /usr/bin/phpize
    Configuring for:
    PHP Api Version: 20151012
    Zend Module Api No: 20151012
    Zend Extension Api No: 320151012

    执行完上一步,我们就有了 configure 配置文件了,接下来配置

    [root@localhost phpredis]#./configure

     或者

    [root@localhost phpredis]#./configure --with-php-config=/usr/bin/php-config

    最后: 

    [root@localhost phpredis]#make && make install 

    配置php的配置文件php.ini(具体放在那里可以用 whereis php.ini 来查看),我的配置文件php.ini在/etc/下

    [root@localhost phpredis]#vim /etc/php.ini

    开启redis扩展:

    extension = redis.so

    最后你会发现这个,看下面!!!

    [root@VM_0_8_centos phpredis]# php -m

    [PHP Modules]

    bz2

    calendar

    Core

    ctype

    curl

    date

    exif

    fileinfo

    filter

    ftp

    gettext

    gmp

    hash

    iconv

    json

    libxml

    mysqli

    openssl

    pcntl

    pcre

    PDO

    pdo_mysql

    pdo_sqlite

    Phar

    readline

    redis                            !!!!我在这里,哈哈

    Reflection

    session

    shmop

    SimpleXML

    sockets

    SPL

    sqlite3

    standard

    tokenizer

    xml

    zip

    zlib

     

    [Zend Modules]

  • 相关阅读:
    pthread_join()
    linux nc
    gcc编译线程程序需带-lpthread选项(否则出错:undefined reference to `pthread_create')
    Makefile中的$(addprefix),添加前缀,指定目标生成目录
    makefile里的Phony
    鱼书学习笔记:激活函数层的实现
    鱼书学习笔记:输出层
    鱼书学习笔记:参数优化
    鱼书学习笔记:利用numpy实现三层神经网络
    鱼书学习笔记:损失函数
  • 原文地址:https://www.cnblogs.com/gaosf/p/9900647.html
Copyright © 2020-2023  润新知