By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,235 Members | 1,601 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,235 IT Pros & Developers. It's quick & easy.

Forcing Server mode

P: n/a
I've been through the docs and I'm more than a little confused: I'd
like to run [some] PHP apps as ordinary CGI programs. I though/hoped
there'd be a command line switch [that I could put in my shebang line]
that'd tell PHP to run in SERVER mode, but I couldn't find it... Is
there a way to do that?

[meta question: is there a way to get Apache to use mod_php on a
shebang'ed PHP program... that'd be best, of course..:o)]

Thanks! /bernie\

Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On Wed, 27 Apr 2005 14:34:30 -0400, Bernard Cosell <be****@rev.net> wrote:
I've been through the docs and I'm more than a little confused: I'd
like to run [some] PHP apps as ordinary CGI programs. I though/hoped
there'd be a command line switch [that I could put in my shebang line]
that'd tell PHP to run in SERVER mode, but I couldn't find it... Is
there a way to do that?
What is "SERVER mode"?
[meta question: is there a way to get Apache to use mod_php on a
shebang'ed PHP program... that'd be best, of course..:o)]


Don't think so - it'll output the shebang as literal text.

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #2

P: n/a
Andy Hassall <an**@andyh.co.uk> wrote:

} On Wed, 27 Apr 2005 14:34:30 -0400, Bernard Cosell <be****@rev.net> wrote:
}
} >I've been through the docs and I'm more than a little confused: I'd
} >like to run [some] PHP apps as ordinary CGI programs. I though/hoped
} >there'd be a command line switch [that I could put in my shebang line]
} >that'd tell PHP to run in SERVER mode, but I couldn't find it... Is
} >there a way to do that?
}
} What is "SERVER mode"?

I'm sure I'm getting the terminology wrong: I have a PHP program that when
run *by* Apache works fine, but when I run it directly [either from the
command line or have Apache run it as a CGI program, it won't produce the
HTTP headers. Even with explicit "header" calls in the program, it won't
make a legal HTML/HTTP web page [OTOH, if I put in an explicit "print
"Content-type...etc" it works fine].

There is something afoot that I don't understand about getting PHP to
output the HTTP headers [even when called as a CGI]...
} >[meta question: is there a way to get Apache to use mod_php on a
} >shebang'ed PHP program... that'd be best, of course..:o)]
}
} Don't think so - it'll output the shebang as literal text.

That doesn't seem to be happening for me:

$ cat test.php
#!/usr/bin/php
<html>
<body>
hello
</body>
</html>

$ php test.php
<html>
<body>
hello
</body>
</html>

No 'headers' and such [which is making it REAL hard to debug this PHP/CGI
program I'm working on], but also no shebang line!

/Bernie\
--
Bernie Cosell Fantasy Farm Fibers
be****@fantasyfarm.com Pearisburg, VA
--> Too many people, too few sheep <--
Jul 17 '05 #3

P: n/a
I think you are confusing the CLI with the CGI. CLI does not output
headers while CGI does. Try php -v to see what you have. And read:

http://php.net/features.commandline

Jul 17 '05 #4

P: n/a
"Philip Olson" <ph*********@gmail.com> wrote:

} I think you are confusing the CLI with the CGI. CLI does not output
} headers while CGI does.

AHA... !THANKS! I was definitely confused, but in an odd way. This page:

} http://php.net/features.commandline

Made clear what's going on for me. It hadn't occurred to me that PHP would
come with two *DIFFERENT* standalone executable options... I assumed that
PHP was just PHP....

Indeed: the sysadmins do have the 'cli' version compiled up, and that means
that I can't (very easily) use PHP for direct-CGI applications [since the
direct-CGI apps will use the executable in /usr/bin, which is the CLI
version] or for debugging my web apps. Too bad that's a compile-time
option instead of a runtime one -- the web server apparently has "mod_php"
hardwired in and that's the only way to get at a "CGI aware" version of PHP
in our environment.

I'm going to get them to update our PHP install [which gives me a little
"say" in how it is configured :o)]... My feeling is that we'll be best
served by having the standalone executable be compiled as the 'CGI' version
-- my primary interest in using PHP is for web stuff -- we have other
tools/languages we can/do use for developing system apps and such...

thanks for clearing up this mini-mystery...

/Bernie\

--
Bernie Cosell Fantasy Farm Fibers
be****@fantasyfarm.com Pearisburg, VA
--> Too many people, too few sheep <--
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.