|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-10-20 12:17 UTC] Bjorn dot Wiberg at its dot uu dot se
Description: ------------ Hi! I have tried using both the /apache/etc/magic file from Apache 2.0.52 and the extras/magic.mime file (from the PHP 5.0.2 for Windows zip archive), but phpinfo() always tells me: mime_magic mime_magic support invalid magic file, disabled Directive Local Value Master Value mime_magic.debug On Off mime_magic.magicfile /apache/etc/magic no value I configured PHP with "--with-mime-magic" but without "--enable-debug", and have set the following in my httpd.conf: php_admin_flag display_errors off php_admin_flag display_startup_errors on php_admin_flag mime_magic.debug on php_admin_value mime_magic.magicfile "/apache/etc/magic" PHP mentions nothing about the erroneous magic file in the Apache error log, however. I would appreciate if someone could provide me with a known working magic.mime file to try. Thanks in advance! Best regards, Bj?rn Reproduce code: --------------- Start Apache, run a PHP script containing phpinfo(), and watch the output. Expected result: ---------------- That mime_magic was enabled, and that there was nothing wrong with the magic file. Actual result: -------------- The mime_magic extension states that the magic file is invalid, but doesn't give any more information. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 14:00:01 2025 UTC |
It seems that the real error behind this is that the PHP mime_magic extension does NOT obey "php_admin_value mime_magic.magicfile" or "php_value mime_magic.magicfile" directives in httpd.conf, although the documentation states that mime_magic.magicfile should be settable from PHP_INI_SYSTEM, i.e., from php.ini and httpd.conf. Apache 2 httpd.conf: php_admin_value mime_magic.magicfile "/apache/etc/magic" Test script: <?php echo mime_content_type('a'); ?> Apache 2 error log: [client 130.238.x.x] PHP Fatal error: mime_content_type(): mime_magic could not be initialized, magic file is not avaliable in /apache/htdocs/test/filtyp.php on line 1 Observe the empty file name in the log output! (I did not supply a name along with --with-mime-magic during configuration, and no magic file is available in what mime_magic considers "standard" locations.) Adding the following to php.ini correctly configures mime_magic (using the Apache 2.0.52-supplied magic file): [mime_magic] mime_magic.magicfile = "/etc/apache/magic" Browser output ('a' is a text file): text/plain Furthermore, phpinfo() will SHOW any httpd.conf setting of mime_magic.magicfile that you make, but still not actually USE anything but what you specified in php.ini! Best regards, Bj?rn