纸水仙 发表于 2018-12-15 12:05:26

9_php扩展模块的安装

  在此处楼主遇到一个问题,用命令查看,居然不出现php 的模块。
  # /usr/local/php/bin/php -m
  于是进行到目录下这样操作,才出现,望解:
  # cd /usr/local/php/bin
  # ls
  pearpeardevpeclpharphar.pharphpphp-cgiphp-configphpdbgphpize
  # php -m
  # 此时静态或动态文件是看不出来的。动态的是可以在 php.ini 里面去定义。
  Core
  ctype
  date
  dom
  ereg
  fileinfo
  filter
  hash
  iconv
  json
  libxml
  mysqli
  pcre
  PDO
  pdo_sqlite
  Phar
  posix
  Reflection
  session
  SimpleXML
  SPL
  sqlite3
  standard
  tokenizer
  xml
  xmlreader
  xmlwriter
  

  
  

  有时候我们会发现有些模块没有编译进来,有两种办法,一是找到源码包重编译。二使用动态的方式来加载。类似于apache 的动态共享模块。
  下面我们就来用第二种方法,编译一个动态的共享模块。
  # cd /usr/local/src/php-5.6.24#进到php 的源码包
  # ls
  acinclude.m4      generated_lists   Makefile.global      README.MAILINGLIST_RULES          server-tests-config.php
  aclocal.m4      genfiles            Makefile.objects   README.md                         server-tests.php
  build             header            makerpm            README.namespaces               snapshot
  buildconf         include             missing            README.NEW-OUTPUT-API             stamp-h.in
  buildconf.bat   INSTALL             mkinstalldirs      README.PARAMETER_PARSING_API      stub.c
  CODING_STANDARDSinstall-sh          modules            README.REDIST.BINS                tests
  config.guess      libphp5.la          netware            README.RELEASE_PROCESS            travis
  config.log      libs                NEWS               README.SELF-CONTAINED-EXTENSIONSTSRM
  config.nice       libtool             pear               README.STREAMS                  UPGRADING
  config.status   LICENSE             php5.spec            README.SUBMITTING_PATCH         UPGRADING.INTERNALS
  config.sub      ltmain.sh         php5.spec.in         README.TESTING                  vcsclean
  configure         main                php.gif            README.TESTING2                   win32
  configure.in      makedist            php.ini-developmentREADME.UNIX-BUILD-SYSTEM          Zend
  CREDITS         Makefile            php.ini-production   README.WIN32-BUILD-SYSTEM
  ext               Makefile.frag       README.EXT_SKEL      run-tests.php
  EXTENSIONS      Makefile.fragmentsREADME.GIT-RULES   sapi
  footer            Makefile.gcov       README.input_filterscripts
  

  # cd ext/# php 所有的块都在这个目录下
  # ls
  bcmath      dom               ftp      intl      mysqli   pdo         pgsql       shmop      standard   xml
  bz2         enchant             gd         json      mysqlndpdo_dblib   phar      simplexmlsybase_ctxmlreader
  calendar    ereg                gettext    ldap      oci8   pdo_firebirdposix       skeleton   sysvmsg    xmlrpc
  com_dotnetexif                gmp      libxml    odbc   pdo_mysql   pspell      snmp       sysvsem    xmlwriter
  ctype       ext_skel            hash       mbstringopcachepdo_oci       readline    soap       sysvshm    xsl
  curl      ext_skel_win32.phpiconv      mcrypt    opensslpdo_odbc      recode      sockets    tidy       zip
  date      fileinfo            imap       mssql   pcntl    pdo_pgsql   reflectionspl      tokenizerzlib
  dba         filter            interbasemysql   pcre   pdo_sqlite    session   sqlite3    wddx
  

  以 curl 为例进行编译:
  # /usr/local/php/bin/php -m |grep -i curl
  # cd curl/
  # ls
  config.m4config.w32CREDITScurl.dspcurl_file.cinterface.cmulti.cpackage.xmlphp_curl.hshare.ctests
  # /usr/l
  lib/   lib64/   libexec/ local/
  # /usr/local/php/bin/phpize   #生成configure 文件
  Configuring for:
  PHP Api Version:         20131106
  Zend Module Api No:      20131226
  Zend Extension Api No:   220131226
  # ls
  acinclude.m4    build         config.m4   configure.incurl.dsp   interface.c      missing      package.xml    share.c
  aclocal.m4      config.guessconfig.subconfig.w32    curl_file.cltmain.sh      mkinstalldirsphp_curl.h   tests
  autom4te.cacheconfig.h.in   configure   CREDITS       install-sh   Makefile.globalmulti.c      run-tests.php
  # ./configure --with-php-config=/usr/local/php/bin/php-config
  ———————————————————————————————————————————————
  楼主在编译的过程中出现了报错,那么就停下解决问题
  

  
  configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
  

  # cd /usr/local/src/
  

  # wget https://github.com/skvadrik/re2c/releases/download/0.13.6/re2c-0.13.6.tar.gz
  # tar xf re2c 0.13.4.tar.gz
  # cd re2c 0.13.4
  # ./configure

  #make && make install
  后面还是出错
  checking for cURL in default path... not found
  configure: error: Please reinstall the libcurl distribution -
      easy.h should be in /include/curl/
  在网上找到了解决办法
php安装错误configure: error: Please reinstall the libcurl distribu
今天配置一台server的php支持curl的时候, 出现如下报错
checking for cURL in default path... not found
configure: error: Please reinstall the libcurl distribution -
easy.h should be in /include/curl/
其实就是curl的dev包没有安装, 解决方案:
终端下
# yum -y install curl-devel
然后就可以继续了
排错到此结束,继续
  ———————————————————————————————————————————————
  # make install#/curl.so 模块文件会被放在下面这个目录
  

  Installing shared extensions:   /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/
  

  # ls /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/curl.so
  /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/curl.so
  

  extension_dir 是存放扩展模块的。也是可以自定义的。
  # cd /usr/local/php/bin/
  # php -i |grep extension_dir
  extension_dir => /usr/local/lib/php/extensions/no-debug-non-zts-20131226 => /usr/local/lib/php/extensions/no-debug-non-zts-20131226
  sqlite3.extension_dir => no value => no value
  

  # cd /usr/local/php/bin
  # php -m# 此时是查看不到curl 这个模块的。刚才在php.ini文件将模块名写错
  来做测试 “curl1.so"
  # tail /usr/local/php/logs/php_errors.log
   PHP Warning:PHP Startup: Unable to load dynamic library '/usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/curl1.so' - /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/curl1.so: cannot open shared object file: No such file or directory in Unknown on line 0
  

  # vim /usr/local/php/etc/php.ini
  extension=curl1.so # 修正
  

  正常再重新加载就可以看到 curl这个模块,但是楼主不知是哪里出错了,这个效果没有做出来,但是curl 这个命令可以正常使用。只能先跳过去 了。



页: [1]
查看完整版本: 9_php扩展模块的安装