Connecting Tech Pros Worldwide Help | Site Map

Forcing Server mode

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 12:52 PM
Bernard Cosell
Guest
 
Posts: n/a
Default Forcing Server mode

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\


  #2  
Old July 17th, 2005, 12:52 PM
Andy Hassall
Guest
 
Posts: n/a
Default Re: Forcing Server mode

On Wed, 27 Apr 2005 14:34:30 -0400, Bernard Cosell <bernie@rev.net> wrote:
[color=blue]
>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?[/color]

What is "SERVER mode"?
[color=blue]
>[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)][/color]

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

--
Andy Hassall / <andy@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
  #3  
Old July 17th, 2005, 12:53 PM
Bernie Cosell
Guest
 
Posts: n/a
Default Re: Forcing Server mode

Andy Hassall <andy@andyh.co.uk> wrote:

} On Wed, 27 Apr 2005 14:34:30 -0400, Bernard Cosell <bernie@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
bernie@fantasyfarm.com Pearisburg, VA
--> Too many people, too few sheep <--
  #4  
Old July 17th, 2005, 12:53 PM
Philip Olson
Guest
 
Posts: n/a
Default Re: Forcing Server mode

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

  #5  
Old July 17th, 2005, 12:53 PM
Bernie Cosell
Guest
 
Posts: n/a
Default Re: Forcing Server mode

"Philip Olson" <philipolson@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
bernie@fantasyfarm.com Pearisburg, VA
--> Too many people, too few sheep <--
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.