1. 程式人生 > >PHP動態擴充套件Redis模組

PHP動態擴充套件Redis模組

檢視已有模組

[[email protected] ~]# /usr/local/php/bin/php -m
[PHP Modules]
bz2
Core
...
zlib

[Zend Modules]

下載包,解壓,生成configure檔案


[[email protected] ~]# cd /usr/local/src/
[[email protected] src]# wget https://codeload.github.com/phpredis/phpredis/zip/develo                                          p
--2018-11-22 08:03:30--  https://codeload.github.com/phpredis/phpredis/zip/devel                                          op
Resolving codeload.github.com (codeload.github.com)... 13.229.189.0, 54.251.140.                                          56, 13.250.162.133
Connecting to codeload.github.com (codeload.github.com)|13.229.189.0|:443... con                                          nected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/zip]
Saving to: ‘develop’

    [                         <=>           ] 254,651     33.9KB/s   in 7.3s

2018-11-22 08:03:45 (34.2 KB/s) - ‘develop’ saved [254651]

[
[email protected]
src]# [[email protected] src]# [[email protected] src]# ls apr-1.6.5 httpd-2.4.37.tar.gz apr-1.6.5.tar.gz mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz apr-util-1.6.1 mariadb-10.3.10-linux-glibc_214-x86_64.tar.gz apr-util-1.6.1.tar.gz mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz develop php-5.6.32 httpd-2.2.9 php-5.6.32.tar.bz2 httpd-2.2.9.tar.gz php-7.1.6 httpd-2.4.37 php-7.1.6.tar.bz2 [
[email protected]
src]# mv develop phpredis-dev.zip # 重新命名 [[email protected] src]# unzip phpredis-dev.zip # 解壓 [[email protected] src]# cd phpredis-develop/ [[email protected] phpredis-develop]# /usr/local/php/bin/phpize Configuring for: PHP Api Version: 20131106 Zend Module Api No: 20131226 Zend Extension Api No: 220131226 Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable. Then, rerun this script. # 提示缺少autoconf模組 [
[email protected]
phpredis-develop]# yum install -y autoconf [[email protected] phpredis-develop]# /usr/local/php/bin/phpize # 生成configure Configuring for: PHP Api Version: 20131106 Zend Module Api No: 20131226 Zend Extension Api No: 220131226 [[email protected] phpredis-develop]# ls -l config* # 已生成configure -rwxr-xr-x. 1 root root 45079 Nov 22 08:11 config.guess -rw-r--r--. 1 root root 1776 Nov 22 08:11 config.h.in -rwxr-xr-x. 1 root root 4776 Nov 21 19:39 config.m4 -rwxr-xr-x. 1 root root 35782 Nov 22 08:11 config.sub -rwxr-xr-x. 1 root root 451368 Nov 22 08:11 configure -rw-r--r--. 1 root root 4690 Nov 22 08:11 configure.in -rw-r--r--. 1 root root 923 Nov 21 19:39 config.w32

編譯安裝生成so檔案

[[email protected] phpredis-develop]# ./configure --with-php-config=/usr/local/php/bin/php-config  
[[email protected] phpredis-develop]# make && make install
[[email protected] phpredis-develop]#  /usr/local/php/bin/php -i |grep extension_dir  # 檢視擴充套件模組存放目錄,可以在php.ini中去自定義該路徑
extension_dir => /usr/local/php/lib/php/extensions/no-debug-zts-20131226 => /usr/local/php/lib/php/extensions/no-debug-zts-20131226 
[[email protected] phpredis-develop]# vim /usr/local/php/etc/php.ini # 新增extension=redis.so
[[email protected] phpredis-develop]#  /usr/local/php/bin/php -m|grep redis
redis

檢視自帶的原始碼包

[[email protected] phpredis-develop]# ls /usr/local/src/php-5.6.32/ext/
bcmath              fileinfo   mbstring   pdo_firebird  shmop      tokenizer
bz2                 filter     mcrypt     pdo_mysql     simplexml  wddx
calendar            ftp        mssql      pdo_oci       skeleton   xml
com_dotnet          gd         mysql      pdo_odbc      snmp       xmlreader
ctype               gettext    mysqli     pdo_pgsql     soap       xmlrpc
curl                gmp        mysqlnd    pdo_sqlite    sockets    xmlwriter
date                hash       oci8       pgsql         spl        xsl
dba                 iconv      odbc       phar          sqlite3    zip
dom                 imap       opcache    posix         standard   zlib
enchant             interbase  openssl    pspell        sybase_ct
ereg                intl       pcntl      readline      sysvmsg
exif                json       pcre       recode        sysvsem
ext_skel            ldap       pdo        reflection    sysvshm
ext_skel_win32.php  libxml     pdo_dblib  session       tidy

擴充套件包查詢下載地址: http://pecl.php.net/