Background:
Version < php-5.3 No API to view the file's Mime_type, so you need to compile the extension fileinfo to extend the PHP API (finfo_* series functions). This issue will not exist in the official release package that php-5.3 will pull FileInfo into later.
Software Preparation:
php:php-5.2.14
Fileinfo:fileinfo-1.0.4.tgz
File:file-5.20.tar.gz
1. File Installation
wget FTP://ftp.astron.com/pub/file/file-5.15.tar.gztarfile-5.20 . Tar File-5.20/ . /configure--prefix=/usr/local/services/File-5.20make make Install
2. FileInfo Extended Compilation Installation
wgethttp//pecl.php.net/get/fileinfo-1.0.4.tgzTarZXF fileinfo-1.0.4. TGZCD Fileinfo-1.0.4//usr/local/php/bin/phpize./configure--with-php-config=/usr/local/php/bin/php-config--with-fileinfo=/usr/local/services/file-5.20/ Make#拷贝fileinfo. So to PHP.ini defined in Extension_dirCPfileinfo.so/usr/local/php/extensions/#修改php. INIEcho "extension=fileinfo.so">>/usr/local/php/lib/php.ini
3. Verification
grep Fileinfofileinfo
Note:
1, install the software attention to see./configure--help which indicates the dependency of the library or header file
2. Extended porting, view dependencies, porting need to be aware of: libmagic.so.1 dependency
Ldd/usr/local/php/extensions/fileinfo.so
Linux-vdso.so.1 = (0x00007fff9b7ff000)
Libmagic.so.1 =/usr/local/lib/libmagic.so.1 (0x00007f8493582000)
libc.so.6 =/lib64/libc.so.6 (0x00007f8493342000)
Libz.so.1 =/lib64/libz.so.1 (0x00007f849322d000)
/lib64/ld-linux-x86-64.so.2 (0x00007f84937a4000)
PHP Gets the MIME type type, FileInfo extension