Linux - PHP安装redis扩展

----------------------------------------------------------------------------------------------------------------------==
-----== linux PHP安装redis扩展    【成功!!!!】

1、创建存放目录
    mkdir /fitness/software/phpredis-2.2.4
    cd /fitness/software/phpredis-2.2.4

2、下载资源文件
    wget https://github.com/nicolasff/phpredis/archive/2.2.4.tar.gz

3、加压文件
    tar -zxvf 2.2.4.tar.gz

    [root@iZ8vb2uz59jd5pisp87ljjZ phpredis-2.2.4]# ls
    2.2.4.tar.gz  phpredis-2.2.4

4、进入解压后的文件,用PHP的phpize文件生成configure文件
    cd phpredis-2.2.4
    /fitness/serve/php/bin/phpize

    [root@iZ8vb2uz59jd5pisp87ljjZ phpredis-2.2.4]# /fitness/serve/php/bin/phpize
    Configuring for:
    PHP Api Version:         20131106
    Zend Module Api No:      20131226
    Zend Extension Api No:   220131226

    ls
    [root@iZ8vb2uz59jd5pisp87ljjZ phpredis-2.2.4]# ls
    acinclude.m4     autom4te.cache  config.guess  config.m4   configure.in  CREDITS         install-sh  ltmain.sh        mkdeb-apache2.sh  package.xml      redis_array.c       redis_array_impl.h  redis_session.h  serialize.list
    aclocal.m4       build           config.h      config.sub  config.w32    debian          library.c   Makefile.global  mkdeb.sh          php_redis.h      redis_array.h       redis.c             rpm              tests
    arrays.markdown  common.h        config.h.in   configure   COPYING       debian.control  library.h   missing          mkinstalldirs     README.markdown  redis_array_impl.c  redis_session.c     run-tests.php
    [root@iZ8vb2uz59jd5pisp87ljjZ phpredis-2.2.4]#

    已经看到configure文件

5、配置phpredis
    ./configure --with-php-config=/fitness/serve/php/bin/php-config

    结果:

    creating libtool
    appending configuration tag "CXX" to libtool
    configure: creating ./config.status
    config.status: creating config.h

6、编译、安装
    make && make install

    结果:
    ...
    (cd .libs && rm -f redis.la && ln -s ../redis.la redis.la)
    /bin/sh /fitness/software/phpredis-2.2.4/phpredis-2.2.4/libtool --mode=install cp ./redis.la /fitness/software/phpredis-2.2.4/phpredis-2.2.4/modules
    cp ./.libs/redis.so /fitness/software/phpredis-2.2.4/phpredis-2.2.4/modules/redis.so
    cp ./.libs/redis.lai /fitness/software/phpredis-2.2.4/phpredis-2.2.4/modules/redis.la
    PATH="$PATH:/sbin" ldconfig -n /fitness/software/phpredis-2.2.4/phpredis-2.2.4/modules
    ----------------------------------------------------------------------
    Libraries have been installed in:
       /fitness/software/phpredis-2.2.4/phpredis-2.2.4/modules

    If you ever happen to want to link against installed libraries
    in a given directory, LIBDIR, you must either use libtool, and
    specify the full pathname of the library, or use the `-LLIBDIR'
    flag during linking and do at least one of the following:
       - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
         during execution
       - add LIBDIR to the `LD_RUN_PATH' environment variable
         during linking
       - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
       - have your system administrator add LIBDIR to `/etc/ld.so.conf'

    See any operating system documentation about shared libraries for
    more information, such as the ld(1) and ld.so(8) manual pages.
    ----------------------------------------------------------------------

    Build complete.
    Don't forget to run 'make test'.

    Installing shared extensions:     /fitness/serve/php/lib/php/extensions/no-debug-non-zts-20131226/

    从最后一句【Installing shared extensions:     /fitness/serve/php/lib/php/extensions/no-debug-non-zts-20131226/】就能
    看出文件最后安装的地方!查看:
    [root@iZ8vb2uz59jd5pisp87ljjZ phpredis-2.2.4]# cd /fitness/serve/php/lib/php/extensions/no-debug-non-zts-20131226/
    [root@iZ8vb2uz59jd5pisp87ljjZ no-debug-non-zts-20131226]# ls
    imagick.so  memcached.so  mysql.so  opcache.a  opcache.so  redis.so  xcache.so

    看到redis.so文件

7、查看PHP模块,是否安装redis扩展
    php -m

    [root@iZ8vb2uz59jd5pisp87ljjZ no-debug-non-zts-20131226]# php -m
    PHP Warning:  PHP Startup: Invalid library (maybe not a PHP library) 'mysql.so' in Unknown on line 0
    [PHP Modules]
    bcmath
    Core
    ctype
    curl
    date
    dom
    ereg
    filter
    ftp
    gd
    hash
    iconv
    intl
    json
    libxml
    mbstring
    mcrypt
    mhash
    mysql
    mysqli
    mysqlnd
    openssl
    pcntl
    pcre
    PDO
    pdo_mysql
    pdo_sqlite
    Phar
    posix
    Reflection
    session
    shmop
    SimpleXML
    soap
    sockets
    SPL
    sqlite3
    standard
    sysvsem
    tokenizer
    xml
    xmlreader
    xmlrpc
    xmlwriter
    xsl
    zip
    zlib

    [Zend Modules]

    没有看到redis?!!!

8、php.ini文件配置redis
    cd /fitness/serve/php/lib
    vim php.ini
    加入:
    extension=redis.so

    重启php-fpm
    [root@iZ8vb2uz59jd5pisp87ljjZ lib]# killall php-fpm
    [root@iZ8vb2uz59jd5pisp87ljjZ lib]# service php-fpm start

    再次查看:
    [root@iZ8vb2uz59jd5pisp87ljjZ lib]# php -m
    PHP Warning:  PHP Startup: Invalid library (maybe not a PHP library) 'mysql.so' in Unknown on line 0
    [PHP Modules]
    bcmath
    Core
    ctype
    curl
    date
    dom
    ereg
    filter
    ftp
    gd
    hash
    iconv
    intl
    json
    libxml
    mbstring
    mcrypt
    mhash
    mysql
    mysqli
    mysqlnd
    openssl
    pcntl
    pcre
    PDO
    pdo_mysql
    pdo_sqlite
    Phar
    posix
    redis  ----- 【这里】
    Reflection
    session
    shmop
    SimpleXML
    soap
    sockets
    SPL
    sqlite3
    standard
    sysvsem
    tokenizer
    xml
    xmlreader
    xmlrpc
    xmlwriter
    xsl
    zip
    zlib

    [Zend Modules]

    [root@iZ8vb2uz59jd5pisp87ljjZ lib]#

    终于看到redis!

    搞定!!!!


==----------------------------------------------------------------------------------------------------------------------
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值