From: brian on 13 May 2009 00:43 RHEL5/PHP 5.1.6 I'm having some trouble getting the Fileinfo package working. It installed fine, and phpinfo() says it's enabled. But it consistently returns an empty string when getting the MIME of a file. /usr/share/pear/bin/pecl install fileinfo vi /etc/php.d/fileinfo.ini extension=fileinfo.so ln -s /usr/share/file/magic /etc/magic.mime The code: define('FINFO_PATH', '/usr/share/file/magic'); .... $fi = new finfo(FILEINFO_MIME, FINFO_PATH); $type = $fi->file($file_path); $type is always empty. And, yes, the path to the file is good. This works fine on the dev box (PHP 5.2.6). Unfortunately, the decision to use RHEL5 for production was out of my hands and I'm stuck with this older version. At least, I'm thinking it might be due to that. I didn't see anything in the manual about it, though. I did come across a post[1] online about doing file conversions where the guy mentions rolling an upgrade to 5.2.4 for RHEL5 but wasn't specific as to whether it was necessary to get Fileinfo to work at all. I might try using that upgrade but thought I'd do a sanity check here first. Any other reason it'd be returning nothing? [1] http://bhuga.net/2008/07/setting-your-system-file-conversions-with-file-framework
From: Thodoris on 13 May 2009 06:13 > RHEL5/PHP 5.1.6 > > I'm having some trouble getting the Fileinfo package working. It > installed fine, and phpinfo() says it's enabled. But it consistently > returns an empty string when getting the MIME of a file. > > /usr/share/pear/bin/pecl install fileinfo > vi /etc/php.d/fileinfo.ini > extension=fileinfo.so > > ln -s /usr/share/file/magic /etc/magic.mime > > The code: > > define('FINFO_PATH', '/usr/share/file/magic'); > ... > $fi = new finfo(FILEINFO_MIME, FINFO_PATH); > $type = $fi->file($file_path); > > $type is always empty. And, yes, the path to the file is good. > > This works fine on the dev box (PHP 5.2.6). Unfortunately, the > decision to use RHEL5 for production was out of my hands and I'm stuck > with this older version. At least, I'm thinking it might be due to > that. I didn't see anything in the manual about it, though. > > I did come across a post[1] online about doing file conversions where > the guy mentions rolling an upgrade to 5.2.4 for RHEL5 but wasn't > specific as to whether it was necessary to get Fileinfo to work at > all. I might try using that upgrade but thought I'd do a sanity check > here first. Any other reason it'd be returning nothing? > > > > [1] > http://bhuga.net/2008/07/setting-your-system-file-conversions-with-file-framework > > Is fileinfo pecl extension installed as a package or with pecl? In case it is installed as an rpm try to remove it and install it as an extension in case the package is broken for some reason. Have in mind that you will need the magic_open library for this to work. -- Thodoris
From: brian on 13 May 2009 11:42 Thodoris wrote: > > Is fileinfo pecl extension installed as a package or with pecl? In case > it is installed as an rpm try to remove it and install it as an > extension in case the package is broken for some reason. I installed it with PECL: /usr/share/pear/bin/pecl install fileinfo Other question: where does PECL install this? It's not under /usr/share/pear AFAIK. This is the same as with the dev box, so I don't think it's an issue; I'm just curious. Anyway, as I said, phpinfo() tells me it's installed & enabled. > Have in mind that you will need the magic_open library for this to work. You mean libmagic? I have file-4.17-15.el5_3.1, which provides libmagic, installed. Strangely, for Fedora, it comes in the file-libs package. But I know that, for the dev box, I had to install file-devel to get this all working. Neither of these appear to be available for RHEL, which I'm discovering is a bit "interesting" to deal with, package-wise. The file package also provides /usr/share/file/magic*, which I have. I'd created a link to /etc/magic.mime but decided in the end to just pass the correct path to finfo().
From: Thodoris Goltsios on 13 May 2009 12:25 > Thodoris wrote: >> >> Is fileinfo pecl extension installed as a package or with pecl? In >> case it is installed as an rpm try to remove it and install it as an >> extension in case the package is broken for some reason. > > I installed it with PECL: > > /usr/share/pear/bin/pecl install fileinfo > > Other question: where does PECL install this? It's not under > /usr/share/pear AFAIK. This is the same as with the dev box, so I > don't think it's an issue; I'm just curious. Pear and pecl are different. Pear is used to install pure PHP-coded extensions that you can include in your projects. You can use this piece of code that pear provides by just copying it somewhere and including it though not recommended IMHO. Pecl on the other hand provides C-coded extensions that you need to compile and may provide for eg APIs for known libraries that must exist in your system. That is what pecl command does downloads, compiles and installs the extension. A wild guess is that your modules probably live under the /usr/lib/php/modules directory or in a directory under the /usr/lib/php. > > Anyway, as I said, phpinfo() tells me it's installed & enabled. > >> Have in mind that you will need the magic_open library for this to work. > > You mean libmagic? I have file-4.17-15.el5_3.1, which provides > libmagic, installed. Strangely, for Fedora, it comes in the file-libs > package. But I know that, for the dev box, I had to install file-devel > to get this all working. Neither of these appear to be available for > RHEL, which I'm discovering is a bit "interesting" to deal with, > package-wise. > > The file package also provides /usr/share/file/magic*, which I have. > I'd created a link to /etc/magic.mime but decided in the end to just > pass the correct path to finfo(). > >
From: brian on 13 May 2009 12:41 Thodoris Goltsios wrote: > >> Thodoris wrote: >>> >>> Is fileinfo pecl extension installed as a package or with pecl? In >>> case it is installed as an rpm try to remove it and install it as an >>> extension in case the package is broken for some reason. >> >> I installed it with PECL: >> >> /usr/share/pear/bin/pecl install fileinfo >> >> Other question: where does PECL install this? It's not under >> /usr/share/pear AFAIK. This is the same as with the dev box, so I >> don't think it's an issue; I'm just curious. > > Pear and pecl are different. Pear is used to install pure PHP-coded > extensions that you can include in your projects. You can use this piece > of code that pear provides by just copying it somewhere and including it > though not recommended IMHO. Pecl on the other hand provides C-coded > extensions that you need to compile and may provide for eg APIs for > known libraries that must exist in your system. > > That is what pecl command does downloads, compiles and installs the > extension. Right, of course. I wasn't thinking about that clearly. > A wild guess is that your modules probably live under the > /usr/lib/php/modules directory or in a directory under the /usr/lib/php. fileinfo.so is, indeed, in /usr/lib/php/modules. But I know it's enabled, in any case. So, anyone know if this extension doesn't work well with 5.1.6?
|
Next
|
Last
Pages: 1 2 Prev: Static and/or Dynamic site scraping using PHP Next: html and password management |