[CentOS] associate .php file with php

Mon Aug 22 21:52:29 UTC 2005
Maciej Żenczykowski <maze at cela.pl>

ok, on my centos4.1 system it seems to be built into the kernel and 
automounted so all you need to do is:

this one matches *.php
echo ":php_a:E::php::/usr/bin/php:" > /proc/sys/fs/binfmt_misc/register

this one matches files starting with "<?"
echo ":php_b:M::<?::/usr/bin/php:" > /proc/sys/fs/binfmt_misc/register

this needs to be done after each reboot and has the benefit of not 
requiring changes to the .php files - which would otherwise (with the #!) 
be illegal php/html

The above is written without testing so YMMV...

(not sure if the php files also have to be executable)

The documentation is in
/usr/src/linux-2.6.9-11.EL/Documentation/binfmt_misc.txt

On Mon, 22 Aug 2005, Maciej Żenczykowski wrote:

> The other solution is to use the 'wine solution' which runs dos exe's through 
> wine based on extension.
> It has something to do with setting up misc binary support.
> I can't remember exactly how it's done but you basically load some special 
> kernel module (binfmt_misc I think) and then echo a proper line (containing 
> .php extension information and /usr/bin/php executer + some other misc info) 
> into the proper place in the /proc file system hierarchy. It should be 
> documented somewhere in the kernel docs.
>
> Cheers,
> MaZe.
>
> On Mon, 22 Aug 2005, David Thompson wrote:
>
>> "Jeff Stacey" wrote:
>>> put
>>> 
>>> #!/usr/bin/php
>>> 
>>> at the top of your php script.
>> 
>> ...and be sure the file is executable (mode 755 or similar).
>> 
>> Dave Thompson
>> 
>> 
>> 
>> _______________________________________________
>> CentOS mailing list
>> CentOS at centos.org
>> http://lists.centos.org/mailman/listinfo/centos
>> 
> _______________________________________________
> CentOS mailing list
> CentOS at centos.org
> http://lists.centos.org/mailman/listinfo/centos
>