Forcing Server mode

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bernard Cosell

    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\

  • Andy Hassall

    #2
    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.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool

    Comment

    • Bernie Cosell

      #3
      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@fantasyf arm.com Pearisburg, VA
      --> Too many people, too few sheep <--

      Comment

      • Philip  Olson

        #4
        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:



        Comment

        • Bernie Cosell

          #5
          Re: Forcing Server mode

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

          Comment

          Working...