Centos+PHP模块+exif扩展 (第三方模块)

前端之家收集整理的这篇文章主要介绍了Centos+PHP模块+exif扩展 (第三方模块)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

今日应开发需求,想要显示图片属性信息,于是度娘就告知exif模块可以实现,操作步骤与问题总结吐下;

一、环境介绍

  1. [root@ghzz~]#cat/etc/redhat-release
  2. CentOSrelease6.5(Final)
  3. Youhavenewmailin/var/spool/mail/root
  4. [root@ghzz~]#PHP-v
  5. ZendGuardLoaderrequiresZendEngineAPIversion220121212.
  6. TheZendEngineAPIversion220131226whichisinstalled,isnewer.
  7. ContactZendTechnologiesathttp://www.zend.com/foralaterversionofZendGuardLoader.
  8. PHP5.6.14(cli)(built:Jul7201612:43:11)
  9. Copyright(c)1997-2015ThePHPGroup
  10. ZendEnginev2.6.0,Copyright(c)1998-2015ZendTechnologies
  11. withZendOPcachev7.0.6-dev,Copyright(c)1999-2015,byZendTechnologies

二、查找模块

方法:去PHP安装路径下ext目录下都是模块

cd /root/software/PHP-5.6.14/ext/exif

###这个模块,应该是PHP安装包内自带的,但是./configure编译安装的时候没有加载的包

方法PHP官网

PHP官网地址:http://pecl.php.net/packages.php


三、编译安装 (加载模块)

1)进入PHP存储模块目录

  1. [root@ghzzlsolesen-pel-56d1b7f]#cd/root/software/PHP-5.6.14/ext/exif
  2. [root@ghzzexif]#ll
  3. 总用量196
  4. -rw-r--r--1100010003339302015config.m4
  5. -rw-r--r--1100010003089302015config.w32
  6. -rw-r--r--110001000369302015CREDITS
  7. -rw-r--r--1100010004969302015example.PHP
  8. -rw-r--r--1100010001453319302015exif.c
  9. -rw-r--r--11000100049339302015exif.dsp
  10. -rw-r--r--11000100019539302015package.xml
  11. -rw-r--r--11000100014639302015PHP_exif.h
  12. -rw-r--r--110001000299302015test.PHP
  13. drwxr-xr-x21000100040969302015tests
  14. -rw-r--r--110001000112329302015test.txt

2)使用PHPize添加PHP动态模块

作用:使用PHPize生成

  1. [root@ghzzexif]#/usr/local/PHP/bin/PHPize
  2. Configuringfor:
  3. PHPApiVersion:20131106
  4. ZendModuleApiNo:20131226
  5. ZendExtensionApiNo:220131226
  6. [root@ghzzexif]#./configure-with-PHP-config=/usr/local/PHP/bin/PHP-config
  7. checkingforgrepthathandleslonglinesand-e.../bin/grep
  8. #。。。省略若干字段
  9. checkingwhetherstrippinglibrariesispossible...yes
  10. checkingiflibtoolsupportssharedlibraries...yes
  11. checkingwhethertobuildsharedlibraries...yes
  12. checkingwhethertobuildstaticlibraries...no
  13.  
  14. creatinglibtool
  15. appendingconfigurationtag"CXX"tolibtool
  16. configure:creating./config.status
  17. config.status:creatingconfig.h
  18. [root@ghzzexif]#make&&makeinstall
  19. /bin/sh/root/software/PHP-5.6.14/ext/exif/libtool--mode=compilecc-I.-I/root/software/PHP-5.6.14/ext/exif-DPHP_ATOM_INC-I/root/software/PHP-5.6.14/ext/exif/include-I/root/software/PHP-5.6.14/ext/exif/main-I/root/software/PHP-5.6.14/ext/exif-I/usr/local/PHP/include/PHP-I/usr/local/PHP/include/PHP/main-I/usr/local/PHP/include/PHP/TSRM-I/usr/local/PHP/include/PHP/Zend-I/usr/local/PHP/include/PHP/ext-I/usr/local/PHP/include/PHP/ext/date/lib-DHAVE_CONFIG_H-g-O2-c/root/software/PHP-5.6.14/ext/exif/exif.c-oexif.lo
  20. mkdir.libs
  21. cc-I.-I/root/software/PHP-5.6.14/ext/exif-DPHP_ATOM_INC-I/root/software/PHP-5.6.14/ext/exif/include-I/root/software/PHP-5.6.14/ext/exif/main-I/root/software/PHP-5.6.14/ext/exif-I/usr/local/PHP/include/PHP-I/usr/local/PHP/include/PHP/main-I/usr/local/PHP/include/PHP/TSRM-I/usr/local/PHP/include/PHP/Zend-I/usr/local/PHP/include/PHP/ext-I/usr/local/PHP/include/PHP/ext/date/lib-DHAVE_CONFIG_H-g-O2-c/root/software/PHP-5.6.14/ext/exif/exif.c-fPIC-DPIC-o.libs/exif.o
  22. /bin/sh/root/software/PHP-5.6.14/ext/exif/libtool--mode=linkcc-DPHP_ATOM_INC-I/root/software/PHP-5.6.14/ext/exif/include-I/root/software/PHP-5.6.14/ext/exif/main-I/root/software/PHP-5.6.14/ext/exif-I/usr/local/PHP/include/PHP-I/usr/local/PHP/include/PHP/main-I/usr/local/PHP/include/PHP/TSRM-I/usr/local/PHP/include/PHP/Zend-I/usr/local/PHP/include/PHP/ext-I/usr/local/PHP/include/PHP/ext/date/lib-DHAVE_CONFIG_H-g-O2-oexif.la-export-dynamic-avoid-version-prefer-pic-module-rpath/root/software/PHP-5.6.14/ext/exif/modulesexif.lo
  23. cc-shared.libs/exif.o-Wl,-soname-Wl,exif.so-o.libs/exif.so
  24. creatingexif.la
  25. (cd.libs&&rm-fexif.la&&ln-s../exif.laexif.la)
  26. /bin/sh/root/software/PHP-5.6.14/ext/exif/libtool--mode=installcp./exif.la/root/software/PHP-5.6.14/ext/exif/modules
  27. cp./.libs/exif.so/root/software/PHP-5.6.14/ext/exif/modules/exif.so
  28. cp./.libs/exif.lai/root/software/PHP-5.6.14/ext/exif/modules/exif.la
  29. PATH="$PATH:/sbin"ldconfig-n/root/software/PHP-5.6.14/ext/exif/modules
  30. ----------------------------------------------------------------------
  31. Librarieshavebeeninstalledin:
  32. /root/software/PHP-5.6.14/ext/exif/modules
  33.  
  34. Ifyoueverhappentowanttolinkagainstinstalledlibraries
  35. inagivendirectory,LIBDIR,youmusteitheruselibtool,and
  36. specifythefullpathnameofthelibrary,orusethe`-LLIBDIR'
  37. flagduringlinkinganddoatleastoneofthefollowing:
  38. -addLIBDIRtothe`LD_LIBRARY_PATH'environmentvariable
  39. duringexecution
  40. -addLIBDIRtothe`LD_RUN_PATH'environmentvariable
  41. duringlinking
  42. -usethe`-Wl,--rpath-Wl,LIBDIR'linkerflag
  43. -haveyoursystemadministratoraddLIBDIRto`/etc/ld.so.conf'
  44.  
  45. Seeanyoperatingsystemdocumentationaboutsharedlibrariesfor
  46. moreinformation,suchastheld(1)andld.so(8)manualpages.
  47. ----------------------------------------------------------------------
  48.  
  49. Buildcomplete.
  50. Don'tforgettorun'maketest'.
  51.  
  52. Installingsharedextensions:/usr/local/PHP/lib/PHP/extensions/no-debug-non-zts-20131226/
  53. [root@ghzzexif]#vi/usr/local/PHP/etc/PHP.ini
  54. 查找:extension=再最后一个extension=后面添加extension=“exif.so
  55. [root@ghzzext]#grep-n"exif.so"/usr/local/PHP/etc/PHP.ini
  56. 743:extension="exif.so"
  57. [root@ghzzexif]#/etc/init.d/PHP-fpmrestart##重启加载PHP模块

四、检查模块运行情况及效果

  1. [root@ghzzext]#PHP-m|grepexif
  2. exif

猜你在找的CentOS相关文章