roopurt18 Posted November 21, 2006 Share Posted November 21, 2006 I'm having a bear of a time installing the Fileinfo module.Here is my test script:[code]<?php // fileinfo_test.php $fi = finfo_open(FILEINFO_MIME); echo (($out = finfo_file($fi, 'package.xml')) === false ? 'false' : $out) . "\n"; finfo_close($fi);?>[/code]Here is the error I get:[b]Fatal error: Call to undefined function: finfo_open() in /home/webview/public_html/test/fileinfo_test.php on line 3[/b]As root:[code]> find / -name "fileinfo.so"/usr/local/lib/php/extensions/no-debug-non-zts-20020429/fileinfo.so> find / -name "php.ini"/scripts/php.ini/usr/lib/php.ini/usr/local/Zend/etc/php.ini/usr/local/cpanel/3rdparty/etc/php.ini/usr/local/cpanel/3rdparty/lib/php.ini/usr/local/lib/php.ini[/code]Now I have added into every single php.ini the following:[code]; If you wish to have an extension loaded automatically, use the following; syntax:;; extension=modulename.extension;; For example, on Windows:;; extension=msql.dll;; ... or under UNIX:;; extension=msql.so;; Note that it should be the name of the module only; no directory information; needs to go here. Specify the location of the extension with the; extension_dir directive above.mime_magic.magicfile = "/usr/share/file/magic.mime"extension=fileinfo.so[/code]I then restart the apache server and my script still fails.Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/28004-install-fileinfo/ Share on other sites More sharing options...
roopurt18 Posted November 21, 2006 Author Share Posted November 21, 2006 I swear I did this once before, but perhaps it was in the wrong php.ini file; mental note: make sure you edit php.ini that is displayed in phpinfo().I added:[code]; Directory in which the loadable extensions (modules) reside.extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20020429/" ;[/code]Restarted the server and now phpinfo() is reporting fileinfo support.However, now I get the errors:[b]Warning: finfo_open() [function.finfo-open]: Failed to load magic database at '/usr/share/misc/magic'. in /home/webview/public_html/test/fileinfo_test.php on line 3Warning: finfo_file(): supplied argument is not a valid file_info resource in /home/webview/public_html/test/fileinfo_test.php on line 4Warning: finfo_close(): supplied argument is not a valid file_info resource in /home/webview/public_html/test/fileinfo_test.php on line 5[/b]Anyways, I'm sure I'll figure it out shortly, just posting in case anyone runs into the same problem in the future. Quote Link to comment https://forums.phpfreaks.com/topic/28004-install-fileinfo/#findComment-128132 Share on other sites More sharing options...
roopurt18 Posted November 21, 2006 Author Share Posted November 21, 2006 If I call finfo_open like so: $fi = finfo_open(FILEINFO_MIME, "/usr/share/file/magic");I receive no error. If I leave off the second argument, I get the errors in the above post.Now, looking at http://www.php.net/finfo_open, the following applies to the second argument:[i]Name of a magic database file, usually something like /path/to/magic.mime. If not specified, MAGIC environment variable is used. If this variable is not set neither, /usr/share/misc/magic is used. .mime and/or .mgc is added if appropriate.[/i]Now I've edited .bash_profile as both root and the regular user to have the lines:[code]MAGIC=/usr/share/file/magicexport MAGIC[/code]Logged everything out, went back in, and restarted the apache server. Checking env at the command prompt reveals that MAGIC=/usr/share/file/magic. The apache server is not running as nobody, but as the user whose .bash_profile I modified.For the life of me I can't figure out why it's not using the default value I've specified in the MAGIC environment variable.Any help? Quote Link to comment https://forums.phpfreaks.com/topic/28004-install-fileinfo/#findComment-128177 Share on other sites More sharing options...
wildteen88 Posted November 22, 2006 Share Posted November 22, 2006 finfo is not a PHP extension. It is a PEAR Module you will need to install PEAR first and then install the finfo PEAR module by running this command:[code]$ pear install fileinfo[/code]. Quote Link to comment https://forums.phpfreaks.com/topic/28004-install-fileinfo/#findComment-128729 Share on other sites More sharing options...
roopurt18 Posted November 22, 2006 Author Share Posted November 22, 2006 Thanks for the response wildteen. That was done and it was during that process that the [i]/usr/local/lib/php/extensions/no-debug-non-zts-20020429/[/i] directory was created.However I still had to go in and edit php.ini to include the DSO as an extension. Everything works just fine now except when calling [b]finfo_open[/b] I have to pass the magic file to use, whereas on the old server I didn't. That was the last thing I was trying to fix and I finally gave up and said, "Screw it." I don't call it very often and I'm passing the path to the magic file as a constant defined in a central location so if I ever have to move hosts or change it, it will be a quick process. Quote Link to comment https://forums.phpfreaks.com/topic/28004-install-fileinfo/#findComment-128845 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.