[BusyBox] Question about PHPwith busybox

Hans-Werner Hilse hilse at web.de
Fri Nov 12 11:57:10 UTC 2004


Hi again,

Your post didn't make it to the list yet, maybe you need to repost it?
As this is interesting for all, i'll answer to the ML, i hope it's
understandable for all those who didn't receive Rory's mail.

On Fri, 12 Nov 2004 13:24:36 +0100
"Rory Vieira" <rory.vieira at coolview.nl> wrote:

> > The "equivalent" would be a php CGI. You get it by compiling
> > php for cgi (option of configure-script). You'll have to
> > convince the php app (and that's probably what that patch is
> > for) that it is indeed running as a CGI. I still don't know
> > how PHP works in CGI mode, i tried it myself and it ended in
> > the fact that the php CGI searched for some (non-standard)
> > CGI environment variable which wasn't set and then denied to
> > run as CGI (saying something like "broken gateway", IIRC).
> I have been messing about with this for quite some time, as I was
> interested in replacing Perl as the defacto standard on my linux
> system. However, what Hans suggested isn't quite true.
> My prelimenary tests with php were not with the CGI executable, as it
> didn't work for me.
> It kept spitting errors abount not being able to find an input file
> ?!?

Well, thinking about it, you're right. That 'broken gateway' was an
issue with my httpd, "fnord". I had the same error you had, 'cannot find
input file' or something like this...
But the reason for this *was* that missing environment variable. I've
done a little debugging and code analyzing, it's clearly this issue.

> I ended up using the cli version, which works perfectly...

Well, with exceptions. I was not able to let it do the cookie-management
or read the query string the php way, with $_GET, $_POST etc. It's the
cli, after all...

> This all does have it's troubles when trying to run them...
> Eg naming the files '.php' doesn't help, as busybox doesn't know what
> to do with them...

You could use linux kernel's misc executables support. You can tell the
kernel how to execute PHP files with this. But after all you have the
restrictions mentioned above.

> So in order to get them executed, I have done the following:
> 
> ---snip---
> #!/bin/php
> [...]

Well, that's working, too. But it breaks existing PHP scripts which are
not build for CLI use.

> I anyone has a different method of calling php I'd like to know.

Given above. Read the docs in the kernel's ./Documentation/

> It would be great if the httpd can understand it should run another
> binary than
> what's stated in the shabang...

I'd like to have support for a cgi-mime-type, too. Maybe it's not too
complicated to add either this or a PHP conform environment. I'll maybe
have a look into this this weekend.

HWH



More information about the busybox mailing list