PHP动态扩展模块

  • /usr/local/php/bin/php -m //查看模块
  • 下面安装一个redis的模块
  • cd /usr/local/src/
  • wget https://codeload.github.com/phpredis/phpredis/zip/develop
  • mv develop phpredis-develop.zip
  • unzip phpredis-develop.zip
  • cd phpredis-develop
  • /usr/local/php/bin/phpize //生成configure文件
[root@aminglinux-02 phpredis-develop]# /usr/local/php7/bin/phpize 
Configuring for:
PHP Api Version:         20160303
Zend Module Api No:      20160303
Zend Extension Api No:   320160303
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.
[root@aminglinux-02 phpredis-develop]# yum install -y autoconf
[root@aminglinux-02 phpredis-develop]# /usr/local/php7/bin/phpize 
Configuring for:
PHP Api Version:         20160303
Zend Module Api No:      20160303
Zend Extension Api No:   320160303
[root@aminglinux-02 phpredis-develop]# ls
acinclude.m4       configure          Makefile.global     redis_cluster.c
aclocal.m4         configure.in       missing             redis_cluster.h
arrays.markdown    config.w32         mkdeb-apache2.sh    redis_commands.c
autom4te.cache     COPYING            mkdeb.sh            redis_commands.h
build              crc16.h            mkinstalldirs       redis_session.c
cluster_library.c  CREDITS            package.xml         redis_session.h
cluster_library.h  debian             php_redis.h         rpm
cluster.markdown   debian.control     README.markdown     run-tests.php
common.h           install-sh         redis_array.c       serialize.list
config.guess       ISSUE_TEMPLATE.md  redis_array.h       tests
config.h.in        library.c          redis_array_impl.c
config.m4          library.h          redis_array_impl.h
config.sub         ltmain.sh          redis.c
[root@aminglinux-02 phpredis-develop]# 
  • ./configure --with-php-config=/usr/local/php/bin/php-config
  • make && makeinstall
  • /usr/local/php7/bin/php -i |grep extension_dir //查看扩展模块存放目录,我们可以在php.ini中去自定义该路径
  • vim /usr/local/php7/etc/php.ini //增加一行配置(可以放到文件最后一行) extension = redis.so
;extension=php_xsl.dll
extension=redis.so
  • /usr/local/php7/bin/php -m |grep redis
  • 在PHP的源码包中没有第三方模块的包,但是在PHP源码包的/ext/目录下有好多扩展模块,如果所需要的扩展模块在该目录下,可以直接进行安装不用下载
root@aminglinux-02 ~]# cd /usr/local/src/php-7.1.6/ext/
[root@aminglinux-02 ext]# ls
bcmath              fileinfo   libxml     pdo_firebird  session    tidy
bz2                 filter     mbstring   pdo_mysql     shmop      tokenizer
calendar            ftp        mcrypt     pdo_oci       simplexml  wddx
com_dotnet          gd         mysqli     pdo_odbc      skeleton   xml
ctype               gettext    mysqlnd    pdo_pgsql     snmp       xmlreader
curl                gmp        oci8       pdo_sqlite    soap       xmlrpc
date                hash       odbc       pgsql         sockets    xmlwriter
dba                 iconv      opcache    phar          spl        xsl
dom                 imap       openssl    posix         sqlite3    zip
enchant             interbase  pcntl      pspell        standard   zlib
exif                intl       pcre       readline      sysvmsg
ext_skel            json       pdo        recode        sysvsem
ext_skel_win32.php  ldap       pdo_dblib  reflection    sysvshm

扩展