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

unix and Windows php script compatibility

P: n/a

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
Jul 17 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
On Wed, 17 Sep 2003 17:36:32 +0000, Michael Appelmans wrote:
The hosting service requires that
each php file have #!/usr/local/bin/php at the top.

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
Jul 17 '05 #2

P: n/a
On Wed, 17 Sep 2003 17:43:01 -0400, Jon Trelfa wrote:
a shebang is only required in Perl scripts from my experience.

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.net | forum.digiserv.net
Programming, Web design, development & hosting.

Jul 17 '05 #3

P: n/a
On Wed, 17 Sep 2003 21:41:21 +0000, Ian.H [dS] wrote:
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.


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
Jul 17 '05 #4

P: n/a
Michael Appelmans wrote:
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


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

Jul 17 '05 #5

P: n/a
On Wed, 17 Sep 2003 19:15:49 -0400, Jon Trelfa wrote:
I've always run PHP as an Apache Module so I never
encountered the need for it.

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


Thanks!

No probs.

Regards,

Ian

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

Jul 17 '05 #6

P: n/a
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 <pa****************************@hybris.digiserv.ne t>,
ia*@WINDOZEdigiserv.net says...
On Wed, 17 Sep 2003 17:43:01 -0400, Jon Trelfa wrote:
a shebang is only required in Perl scripts from my experience.

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

Jul 17 '05 #7

P: n/a
Zac Hester <ne**@planetzac.net> writes:
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).


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.

--
"Notwithstanding 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.
Jul 17 '05 #8

P: n/a
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
Jul 17 '05 #9

P: n/a
Bruce Lewis wrote:
Zac Hester <ne**@planetzac.net> writes:

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).

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.


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.

Jul 17 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.