今日應(yīng)開發(fā)需求,想要顯示圖片的屬性信息,于是度娘就告知exif模塊可以實現(xiàn),操作步驟與問題總結(jié)吐下;
創(chuàng)新互聯(lián)公司憑借專業(yè)的設(shè)計團(tuán)隊扎實的技術(shù)支持、優(yōu)質(zhì)高效的服務(wù)意識和豐厚的資源優(yōu)勢,提供專業(yè)的網(wǎng)站策劃、成都網(wǎng)站制作、網(wǎng)站建設(shè)、網(wǎng)站優(yōu)化、軟件開發(fā)、網(wǎng)站改版等服務(wù),在成都10多年的網(wǎng)站建設(shè)設(shè)計經(jīng)驗,為成都上千家中小型企業(yè)策劃設(shè)計了網(wǎng)站。
與Apache+PHP或者Nginx+PHP的運行模式不同,WorkerMan是基于PHP命令行 PHP CLI 運行的,使用的是不同的PHP可執(zhí)行程序,使用的php.ini文件也可能不同。所以在網(wǎng)頁中打印phpinfo()
看到安裝了某個擴(kuò)展,不代表命令行的PHP CLI也安裝了對應(yīng)的擴(kuò)展。
運行 php -m
會列出命令行 PHP CLI 已經(jīng)安裝的擴(kuò)展,結(jié)果類似如下:
~# php -m [PHP Modules] libevent posix pcntl ...
當(dāng)我們安裝擴(kuò)展時,可能需要手動配置php.ini文件,把擴(kuò)展加進(jìn)去,所以要確認(rèn)PHP CLI的php.ini文件的位置??梢赃\行php --ini
查找PHP CLI的ini文件位置,結(jié)果類似如下(各個系統(tǒng)顯示結(jié)果會有差異):
~# php --ini Configuration File (php.ini) Path: /etc/php5/cli Loaded Configuration File: /etc/php5/cli/php.ini Scan for additional .ini files in: /etc/php5/cli/conf.d Additional .ini files parsed: /etc/php5/cli/conf.d/apc.ini, /etc/php5/cli/conf.d/libevent.ini, /etc/php5/cli/conf.d/memcached.ini, /etc/php5/cli/conf.d/MySQL.ini, /etc/php5/cli/conf.d/pdo.ini, /etc/php5/cli/conf.d/pdo_mysql.ini ...
如果PHP是通過 apt 或者 yum 命令安裝的,則擴(kuò)展也可以通過 apt 或者 yum 安裝
debian/ubuntu等系統(tǒng)apt安裝PHP擴(kuò)展方法(非root用戶需要加sudo命令)
1、利用apt-cache search
查找擴(kuò)展包
~# apt-cache search memcached php php-apc - APC (Alternative PHP Cache) module for PHP 5 php5-memcached - memcached module for php5
2、使用apt-get install
安裝擴(kuò)展包
~# apt-get install -y php5-memcached Reading package lists... Done Reading state information... Done ...
centos等系統(tǒng)yum安裝PHP擴(kuò)展方法
1、利用yum search
查找擴(kuò)展包
~# yum search memcached php php-pecl-memcached - memcached module for php5
2、使用yum install
安裝擴(kuò)展包
~# yum install -y php-pecl-memcached Reading package lists... Done Reading state information... Done ...
說明:
使用apt或者yum安裝PHP擴(kuò)展會自動配置php.ini文件,安裝完直接可用,十分方便。缺點是有些擴(kuò)展在apt或者yum中沒有對應(yīng)的擴(kuò)展安裝包。
使用pecl install
命令安裝擴(kuò)展
1、pecl install
安裝
~# pecl install memcached downloading memcached-2.2.0.tgz ... Starting to download memcached-2.2.0.tgz (70,449 bytes) ....
一、環(huán)境介紹
[root@ghzz ~]# cat /etc/redhat-release CentOS release 6.5 (Final) You have new mail in /var/spool/mail/root [root@ghzz ~]# php -v Zend Guard Loader requires Zend Engine API version 220121212. The Zend Engine API version 220131226 which is installed, is newer. Contact Zend Technologies at http://www.zend.com/ for a later version of Zend Guard Loader. PHP 5.6.14 (cli) (built: Jul 7 2016 12:43:11) Copyright (c) 1997-2015 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
二、查找模塊
方法一:去php安裝路徑下ext目錄下都是模塊
cd /root/software/php-5.6.14/ext/exif
如果找不到 find ./ -type d -name "php*" 去查找
###這個模塊,應(yīng)該是php安裝包內(nèi)自帶的,但是./configure編譯安裝的時候沒有加載的包
方法二:php官網(wǎng)
PHP官網(wǎng)地址:http://pecl.php.net/packages.php
三、編譯安裝 (加載模塊)
1)進(jìn)入php存儲模塊目錄
[root@ghzz lsolesen-pel-56d1b7f]# cd /root/software/php-5.6.14/ext/exif ##測試環(huán)境 ##如果找不到 find ./ -type f -name "php-*" 去查找 [root@ghzz exif]# ll 總用量 196 -rw-r--r-- 1 1000 1000 333 9月 30 2015 config.m4 -rw-r--r-- 1 1000 1000 308 9月 30 2015 config.w32 -rw-r--r-- 1 1000 1000 36 9月 30 2015 CREDITS -rw-r--r-- 1 1000 1000 496 9月 30 2015 example.php -rw-r--r-- 1 1000 1000 145331 9月 30 2015 exif.c -rw-r--r-- 1 1000 1000 4933 9月 30 2015 exif.dsp -rw-r--r-- 1 1000 1000 1953 9月 30 2015 package.xml -rw-r--r-- 1 1000 1000 1463 9月 30 2015 php_exif.h -rw-r--r-- 1 1000 1000 29 9月 30 2015 test.php drwxr-xr-x 2 1000 1000 4096 9月 30 2015 tests -rw-r--r-- 1 1000 1000 11232 9月 30 2015 test.txt
2)使用phpize添加php動態(tài)模塊
作用:使用phpize生成
[root@ghzz exif]# /usr/local/php/bin/phpize Configuring for: PHP Api Version: 20131106 Zend Module Api No: 20131226 Zend Extension Api No: 220131226 [root@ghzz exif]# ./configure -with-php-config=/usr/local/php/bin/php-config checking for grep that handles long lines and -e... /bin/grep #。。。省略若干字段 checking whether stripping libraries is possible... yes checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... no creating libtool appending configuration tag "CXX" to libtool configure: creating ./config.status config.status: creating config.h [root@ghzz exif]# make && make install /bin/sh /root/software/php-5.6.14/ext/exif/libtool --mode=compile 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 -o exif.lo mkdir .libs 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 /bin/sh /root/software/php-5.6.14/ext/exif/libtool --mode=link cc -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 -o exif.la -export-dynamic -avoid-version -prefer-pic -module -rpath /root/software/php-5.6.14/ext/exif/modules exif.lo cc -shared .libs/exif.o -Wl,-soname -Wl,exif.so -o .libs/exif.so creating exif.la (cd .libs && rm -f exif.la && ln -s ../exif.la exif.la) /bin/sh /root/software/php-5.6.14/ext/exif/libtool --mode=install cp ./exif.la /root/software/php-5.6.14/ext/exif/modules cp ./.libs/exif.so /root/software/php-5.6.14/ext/exif/modules/exif.so cp ./.libs/exif.lai /root/software/php-5.6.14/ext/exif/modules/exif.la PATH="$PATH:/sbin" ldconfig -n /root/software/php-5.6.14/ext/exif/modules ---------------------------------------------------------------------- Libraries have been installed in: /root/software/php-5.6.14/ext/exif/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: /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/ [root@ghzz exif]# vi /usr/local/php/etc/php.ini ##如果文件路徑不存在,就去安裝目錄查找php.ini文件 查找:extension = 再最后一個extension= 后面添加上extension = “exif.so” [root@ghzz ext]# grep -n "exif.so" /usr/local/php/etc/php.ini 743:extension = "exif.so" [root@ghzz exif]# /etc/init.d/php-fpm restart ##重啟加載php模塊
四、此時可能出現(xiàn)模塊加載報錯
Gracefully shutting down php-fpm . done Starting php-fpm [06-Jan-2017 13:43:43] NOTICE: PHP message: PHP Warning: PHP Startup: Invalid library (maybe not a PHP library) ‘fileinfo.so’ in Unknown on line 0 重新執(zhí)行上面的操作還是一直報這個錯誤
解決方法
到你的模塊安裝目錄,我這里是:
cd /****/soft/lnmp1.2-full/src/php-5.6.14/ext/exif make clean
在重新執(zhí)行上面的全部命令,安裝就成功了
報錯原因:
因為之前編譯的庫文件.so存在異常,所以沒有將新的寫入,有沖突,需要清空后重新編譯,即可啟動
五、檢查模塊運行情況及效果
[root@ghzz ext]# php -m|grep exif exif
標(biāo)題名稱:Centos+PHP模塊+exif擴(kuò)展(第三方模塊)
文章地址:http://jinyejixie.com/article48/gdppep.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供ChatGPT、響應(yīng)式網(wǎng)站、品牌網(wǎng)站設(shè)計、小程序開發(fā)、定制開發(fā)、網(wǎng)站設(shè)計公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)