unix and Windows php script compatibility

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michael Appelmans

    unix and Windows php script compatibility


    I'm a php novice and am developing a shopping cart application for a
    client who is hosted on a unix server. The hosting service requires that
    each php file have #!/usr/local/bin/php at the top. When I test these
    pages on my developer Windows php installation I get errors because
    Windows does not recognize the bang command so it is passed on as
    content to the php server.

    Any suggestions on hiding the first line from windows while still having
    unix see this?

    Any help would be appreciated. This is driving me bonkers.

    Michael
  • Jon Trelfa

    #2
    Re: unix and Windows php script compatibility

    On Wed, 17 Sep 2003 17:36:32 +0000, Michael Appelmans wrote:
    [color=blue]
    > The hosting service requires that
    > each php file have #!/usr/local/bin/php at the top.[/color]


    My first suggestion is to get a new hosting service...a shebang is only
    required in Perl scripts from my experience. Have you tried executing PHP
    scripts on this hosting service without the shebang and just using <?PHP
    to open the script?

    --
    Jon Trelfa
    Registered Linux User #164332
    There 10 kinds of people in this world...
    Those who understand binary and those who don't

    Comment

    • Ian.H [dS]

      #3
      Re: unix and Windows php script compatibility

      On Wed, 17 Sep 2003 17:43:01 -0400, Jon Trelfa wrote:
      [color=blue]
      > a shebang is only required in Perl scripts from my experience.[/color]


      Nope.. if you write a PHP cmdline script, you need to include a shebang
      line, unless of course, you exec it as: 'php foo.php'.

      Sounds like the hosting server is running PHP in CGI mode rather than as a
      module, hence the requirement of the shebang line as this is then
      interpreted in the same way a Perl script is.



      Regards,

      Ian

      --
      Ian.H [Design & Development]
      digiServ Network - Web solutions
      www.digiserv.net | irc.digiserv.ne t | forum.digiserv. net
      Programming, Web design, development & hosting.

      Comment

      • Jon Trelfa

        #4
        Re: unix and Windows php script compatibility

        On Wed, 17 Sep 2003 21:41:21 +0000, Ian.H [dS] wrote:
        [color=blue]
        > Sounds like the hosting server is running PHP in CGI mode rather than as a
        > module, hence the requirement of the shebang line as this is then
        > interpreted in the same way a Perl script is.
        >[/color]

        I stand corrected. I've always run PHP as an Apache Module so I never
        encountered the need for it.

        Thanks!

        --
        Jon Trelfa
        Registered Linux User #164332
        There 10 kinds of people in this world...
        Those who understand binary and those who don't

        Comment

        • Zac Hester

          #5
          Re: unix and Windows php script compatibility

          Michael Appelmans wrote:
          [color=blue]
          > I'm a php novice and am developing a shopping cart application for a
          > client who is hosted on a unix server. The hosting service requires that
          > each php file have #!/usr/local/bin/php at the top. When I test these
          > pages on my developer Windows php installation I get errors because
          > Windows does not recognize the bang command so it is passed on as
          > content to the php server.
          >
          > Any suggestions on hiding the first line from windows while still having
          > unix see this?
          >
          > Any help would be appreciated. This is driving me bonkers.
          >
          > Michael
          >[/color]

          It looks like they only want you to use PHP as CGI (a Bad Thing (tm)).
          If this hosting provider is advertising that they allow PHP on their
          servers, they're only half right (IMO).

          I would get a new provider or tell them that you want PHP parsing done
          within the HTTP stream (ie. put the correct settings in their web
          server's config). If very many people are running PHP on their server,
          it will also alleviate some load since running CGI PHP is more
          resource-intensive than running PHP in module form (based on my
          experience with Apache).

          If there's no way around this, look up using PHP as CGI (chapter 3 in
          the manual: "Servers-CGI/Commandline," or, better yet, try Google: "php
          cgi").

          HTH,
          Zac

          Comment

          • Ian.H [dS]

            #6
            Re: unix and Windows php script compatibility

            On Wed, 17 Sep 2003 19:15:49 -0400, Jon Trelfa wrote:
            [color=blue]
            > I've always run PHP as an Apache Module so I never
            > encountered the need for it.[/color]


            I do too Jon.. never have tried CGI mode.. just picked up snippets of info
            along the way =)

            [color=blue]
            >
            > Thanks![/color]


            No probs.



            Regards,

            Ian

            --
            Ian.H [Design & Development]
            digiServ Network - Web solutions
            www.digiserv.net | irc.digiserv.ne t | forum.digiserv. net
            Programming, Web design, development & hosting.

            Comment

            • Michael Appelmans

              #7
              Re: unix and Windows php script compatibility

              Well there you have it, I've inherited another can of worms, a site on a
              web hosting service (XO.com) running PHP in cgi mode (shades of the dark
              ages,eh?). I guess I can comment and uncomment the directive based on
              which OS but a pain in the derriere. Would be cool to have a script to
              automate that. Maybe I'll have to dust off my Rebol.

              Thanks for the comments.

              Michael

              In article <pan.2003.09.17 .21.42.03.24359 5@hybris.digise rv.net>,
              ian@WINDOZEdigi serv.net says...[color=blue]
              > On Wed, 17 Sep 2003 17:43:01 -0400, Jon Trelfa wrote:
              >[color=green]
              > > a shebang is only required in Perl scripts from my experience.[/color]
              >
              >
              > Nope.. if you write a PHP cmdline script, you need to include a shebang
              > line, unless of course, you exec it as: 'php foo.php'.
              >
              > Sounds like the hosting server is running PHP in CGI mode rather than as a
              > module, hence the requirement of the shebang line as this is then
              > interpreted in the same way a Perl script is.
              >
              >
              >
              > Regards,
              >
              > Ian
              >
              >[/color]

              Comment

              • Bruce Lewis

                #8
                Re: unix and Windows php script compatibility

                Zac Hester <news@planetzac .net> writes:
                [color=blue]
                > I would get a new provider or tell them that you want PHP parsing done
                > within the HTTP stream (ie. put the correct settings in their web
                > server's config). If very many people are running PHP on their
                > server, it will also alleviate some load since running CGI PHP is more
                > resource-intensive than running PHP in module form (based on my
                > experience with Apache).[/color]

                Maybe this hosting provider does some kind of cgiwrap thing to have the
                PHP scripts run under the user's own id. If so, I can understand why
                they'd want to do it that way.

                --
                "Notwithstandin g fervent argument that patent protection is essential
                for the growth of the software industry, commentators have noted
                that `this industry is growing by leaps and bounds without it.'"
                -- US Supreme Court Justice John Paul Stevens, March 3, 1981.

                Comment

                • Bogdan

                  #9
                  Re: unix and Windows php script compatibility

                  The stupid but easy way to do this is to use something like EditPad
                  Plus or something like that. You can do something like <!-- PHP
                  Location --> on windows and then do find and replace in all files.
                  EditPad does global replace.

                  - Bogdan

                  Comment

                  • Zac Hester

                    #10
                    Re: unix and Windows php script compatibility

                    Bruce Lewis wrote:[color=blue]
                    > Zac Hester <news@planetzac .net> writes:
                    >
                    >[color=green]
                    >>I would get a new provider or tell them that you want PHP parsing done
                    >>within the HTTP stream (ie. put the correct settings in their web
                    >>server's config). If very many people are running PHP on their
                    >>server, it will also alleviate some load since running CGI PHP is more
                    >>resource-intensive than running PHP in module form (based on my
                    >>experience with Apache).[/color]
                    >
                    >
                    > Maybe this hosting provider does some kind of cgiwrap thing to have the
                    > PHP scripts run under the user's own id. If so, I can understand why
                    > they'd want to do it that way.
                    >[/color]

                    Indeed, it would be understandable. Doing some kind of setuid scheme
                    with the PHP CGI binary would have security advantages over having the
                    PHP scripts running under the web server's user (as an Apache module).

                    However, in favor of efficiency, I would rather just run my web server
                    as an unpriveledged user and let everyone run PHP as a preprocessor
                    instead of CGI (which is how we do it where I work--ISP with a good bit
                    of web hosting to throw around).

                    I guess it depends on who's trying to hack your web server (outside
                    attacks (like DoS) or people who have purchased your service and have an
                    account on your server). Then, one method would clearly be better than
                    the other in only one case.

                    Comment

                    Working...