The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Rebuilding Apache/PHP with mime_magic

Discussion in 'EasyApache' started by verdon, Jul 25, 2005.

  1. verdon

    verdon Well-Known Member

    Joined:
    Nov 1, 2003
    Messages:
    836
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    Northern Ontario, Canada
    cPanel Access Level:
    Root Administrator
    Hi :)

    I need to rebuild apache/php with support for mime_magic. I have a script that requires the php function mime_content_type() Is that what the option 'MM (Version 1.3.1)' is for in buildapache?

    I can't seem to find much reference when searching here for terms mime, mime-magic, mime.magic, mime magic, MM (Version 1.3.1), and so on.

    Thanks,
     
  2. aegis

    aegis Well-Known Member

    Joined:
    Jul 6, 2003
    Messages:
    64
    Likes Received:
    0
    Trophy Points:
    6
    Hi Verdon, ;-)

    MM is a shared memory module. See http://www.ossp.org/pkg/lib/mm/

    To get that PHP function working you need to compile php with --with-magic-mime and install the Apache module http://httpd.apache.org/docs/1.3/mod/mod_mime_magic.html

    Problem is, it's already deprecated in PHP in favour of the PECL fileinfo package. See http://uk2.php.net/manual/en/ref.mime-magic.php which is annoying as the PEAR MIME/Type package still relies on the deprecated function.

    You can install the PECL package with...

    'pear install fileinfo'

    ...in theory. It just gave me an error though...

    downloading Fileinfo-1.0.tgz ...
    Starting to download Fileinfo-1.0.tgz (5,566 bytes)
    .....done: 5,566 bytes
    3 source files, building
    running: phpize
    Configuring for:
    PHP Api Version: 20020918
    Zend Module Api No: 20020429
    Zend Extension Api No: 20021010
    building in /var/tmp/pear-build-root/Fileinfo-1.0
    running: /tmp/tmpmtRqMV/Fileinfo-1.0/configure
    sh: /tmp/tmpmtRqMV/Fileinfo-1.0/configure: /bin/sh: bad interpreter: Permission denied
    `/tmp/tmpmtRqMV/Fileinfo-1.0/configure' failed


    Sigh.
     
  3. verdon

    verdon Well-Known Member

    Joined:
    Nov 1, 2003
    Messages:
    836
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    Northern Ontario, Canada
    cPanel Access Level:
    Root Administrator
    Thanks aegis,

    You've given me some ideas and places to start to look. It is the Pear MIME/Type.php autoDetect() in particular that I'm trying to get to work. Works on my local server (MacOSX/Apache/PHP4.3.9) where I do have mime_content_type() available. I can't get it to work on my production server (CentOS3.5/Apache/PHP4.3.9) where I do not have mime_content_type() available. Strange thing is, that:
    Code:
    if (!function_exists('mime_content_type')) {
        function mime_content_type($f) {
            $f = escapeshellarg($f);
            return trim( `file -bi $f` );
        }
    }
    $type = mime_content_type($file);
    will work on my production server, which is what I roughly thought MIME/Type.php autoDetect() fell back on if mime_content_type() isn't available, before it returns an error.

    Guess I've got more reading and poking to do ;) Again, thanks for the pointers.
     
  4. payne

    payne Well-Known Member

    Joined:
    May 31, 2003
    Messages:
    103
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Seattle
    aegis, I'm having the same problem installing. I think it is because I have cpanel set up to not allow execution of scripts in the /tmp folder, which is where pear install wants to sh the installation script. I haven't figured out how to tell pear to install it from somewhere else, yet. I'd like to, though, as I don't want to manually install every time I want a package.
     
  5. payne

    payne Well-Known Member

    Joined:
    May 31, 2003
    Messages:
    103
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Seattle
    mount -o remount,exec /tmp
    pecl install Fileinfo
    mount -o remount /tmp
     
Loading...

Share This Page