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

Need help on PHP

P: n/a
Hi, I begin to write PHP but run into problem already.
First, I do not know where to put my PHP code? Where is the IIS Root
Directory? (I'm using Windows XP).

I have run Installer... but when I open my browser and type:
http://localhost/hello.php, what I got is an error message:

<p>This PHP CGI binary was compiled with force-cgi-redirect enabled.
This
means that a page will only be served up if the REDIRECT_STATUS CGI
variable is
set, e.g. via an Apache Action directive.</p>
<p>For more information as to <i>why</i> this behaviour exists, see the
<a href="http://php.net/security.cgi-bin">manual page for CGI
security</a>.</p>
<p>For more information about changing this behaviour or re-enabling
this webserver,
consult the installation file that came with this distribution, or
visit
<a href="http://php.net/install.windows">the manual page</a>.</p>

I really do not understand how to make my first PHP "Hello World"
works?

I will greatly appreciate of your help!
Thank you!

-Ted

Jun 22 '06 #1
Share this Question
Share on Google+
18 Replies


P: n/a

teddybear wrote:
Hi, I begin to write PHP but run into problem already.
First, I do not know where to put my PHP code? Where is the IIS Root
Directory? (I'm using Windows XP).


Your root directory is c:\Inetpub\wwwroot

Jun 22 '06 #2

P: 6
Thanks for your suggestion on the root directory. Now I have put it there, but still gave me error with the same message when I call it from the web browser: http://127.0.0.1/hello.php.

Here is the error message:
<p>This PHP CGI binary was compiled with force-cgi-redirect enabled.
This
means that a page will only be served up if the REDIRECT_STATUS CGI
variable is
set, e.g. via an Apache Action directive.</p>
<p>For more information as to <i>why</i> this behaviour exists, see the
<a href="http://php.net/security.cgi-bin">manual page for CGI
security</a>.</p>
<p>For more information about changing this behaviour or re-enabling
this webserver,
consult the installation file that came with this distribution, or
visit
<a href="http://php.net/install.windows">the manual page</a>.</p>

I do not know where to fix??
Jun 22 '06 #3

P: n/a
WhatsPHP wrote:
teddybear wrote:
Hi, I begin to write PHP but run into problem already.
First, I do not know where to put my PHP code? Where is the IIS Root
Directory? (I'm using Windows XP).


Your root directory is c:\Inetpub\wwwroot


Thanks for reminding me that I have to put my hello.php in the
C:\Inetpub\wwwroot folder. I have put it there, but when I try to call
with http://127.0.0.1/hello.php,

the problem still there, it said:

<p>This PHP CGI binary was compiled with force-cgi-redirect enabled.
This
means that a page will only be served up if the REDIRECT_STATUS CGI
variable is
set, e.g. via an Apache Action directive.</p>
<p>For more information as to <i>why</i> this behaviour exists, see the
<a href="http://php.net/security.cgi-bin">manual page for CGI
security</a>.</p>
<p>For more information about changing this behaviour or re-enabling
this webserver,
consult the installation file that came with this distribution, or
visit
<a href="http://php.net/install.windows">the manual page</a>.</p>

What is the problem? Can it be that I have to point in the PATH where
the PHP compiler is? Or should I modify the REDIRECT_STATUS CGI
variable as stated above, and where I can find the REDIRECT_STATUS
variable?
Please help and thank you!

--Ted

Jun 22 '06 #4

P: n/a
This PHP CGI binary was compiled with force-cgi-redirect enabled. This
means that a page will only be served up if the REDIRECT_STATUS CGI
variable is set, e.g. via an Apache Action directive.

First thing you need to do is change the line in php.ini so it is
cgi.force_redirect = Off

Then - and this is where I tore my hair out for a while - if you have
your php.ini in the /windows directory, ensure there there isn't also a
default php.ini in the PHP directory as it seems to read that one
first.

Or, why not just have it in the PHP directory and save a lot of
heartache :o)

Jun 22 '06 #5

P: 6
Okay, I read and follow your reply... I found there is PHP.ini in my /windows directory. And then, I found out that there is also another PHP.ini in my /PHP directory.

Your suggestion is to DELETE the one inside windows directory. Do I interpret your suggestion correctly?

And then, change the cgi.force_redirect = 0?

Here is the section regarding cgi.force_redirect from PHP.ini inside /PHP folder:
----
; cgi.force_redirect is necessary to provide security running PHP as a CGI under
; most web servers. Left undefined, PHP turns this on by default. You can
; turn it off here AT YOUR OWN RISK
; **You CAN safely turn this off for IIS, in fact, you MUST.**
; cgi.force_redirect = 1
------

And here is the one inside my PHP.ini in the /Windows folder:
------
; cgi.force_redirect is necessary to provide security running PHP as a CGI under
; most web servers. Left undefined, PHP turns this on by default. You can
; turn it off here AT YOUR OWN RISK
; **You CAN safely turn this off for IIS, in fact, you MUST.**
; cgi.force_redirect = 1
cgi.force_redirect = 0

-----

The one in the /windows directory says cgi.force_redirect = OFF?
While the one in the /PHP directory is commented, so it has no effect.

Now, what else I have to do if I have to let only the one in /PHP directory, if there are more steps to be done... should I restart my computer so the modified PHP.ini have the effect?

Thanks...

--Ted
Jun 22 '06 #6

P: n/a
I have replied you on the scripts.com forum. Thanks, and I am looking
forward to your reply!

WhatsPHP wrote:
This PHP CGI binary was compiled with force-cgi-redirect enabled. This
means that a page will only be served up if the REDIRECT_STATUS CGI
variable is set, e.g. via an Apache Action directive.

First thing you need to do is change the line in php.ini so it is
cgi.force_redirect = Off

Then - and this is where I tore my hair out for a while - if you have
your php.ini in the /windows directory, ensure there there isn't also a
default php.ini in the PHP directory as it seems to read that one
first.

Or, why not just have it in the PHP directory and save a lot of
heartache :o)


Jun 22 '06 #7

P: 6
Well, I am not aware that this forum apparently link to the one in google group.

Now, I got different problem. I have set the PHP.ini in the \PHP directory with
cgi.force_redirect = 0

So, that should override the one in the /windows directory. But when I call my hello.php, my browser said: "Page Could Not Be Found"

Why is it so? I already put my Hello.php both in the /wwwroot directory and /PHP directory...

Another problem again and do not know where to fix? Please help!
Thanks!
Jun 22 '06 #8

P: n/a
I have another problem now. My browser said "Page Coult Not Be Found".
However I have set cgi.force_redirect = 0 in the PHP.ini inside /PHP
directory,
And I have put Hello.PHP both in the /wwwroot directory and /PHP
directory.
Can you please suggest me what is the problem this time?

Thank you for help!

--Ted

teddybear wrote:
I have replied you on the scripts.com forum. Thanks, and I am looking
forward to your reply!

WhatsPHP wrote:
This PHP CGI binary was compiled with force-cgi-redirect enabled. This
means that a page will only be served up if the REDIRECT_STATUS CGI
variable is set, e.g. via an Apache Action directive.

First thing you need to do is change the line in php.ini so it is
cgi.force_redirect = Off

Then - and this is where I tore my hair out for a while - if you have
your php.ini in the /windows directory, ensure there there isn't also a
default php.ini in the PHP directory as it seems to read that one
first.

Or, why not just have it in the PHP directory and save a lot of
heartache :o)


Jun 22 '06 #9

P: n/a
My friend, where are you going? Anybody out there, please help???
I am stuck...

teddybear wrote:
I have another problem now. My browser said "Page Coult Not Be Found".
However I have set cgi.force_redirect = 0 in the PHP.ini inside /PHP
directory,
And I have put Hello.PHP both in the /wwwroot directory and /PHP
directory.
Can you please suggest me what is the problem this time?

Thank you for help!

--Ted

teddybear wrote:
I have replied you on the scripts.com forum. Thanks, and I am looking
forward to your reply!

WhatsPHP wrote:
This PHP CGI binary was compiled with force-cgi-redirect enabled. This
means that a page will only be served up if the REDIRECT_STATUS CGI
variable is set, e.g. via an Apache Action directive.

First thing you need to do is change the line in php.ini so it is
cgi.force_redirect = Off

Then - and this is where I tore my hair out for a while - if you have
your php.ini in the /windows directory, ensure there there isn't also a
default php.ini in the PHP directory as it seems to read that one
first.

Or, why not just have it in the PHP directory and save a lot of
heartache :o)


Jun 23 '06 #10

P: n/a

teddybear wrote:
My friend, where are you going? Anybody out there, please help???
I am stuck...

teddybear wrote:
I have another problem now. My browser said "Page Coult Not Be Found".
However I have set cgi.force_redirect = 0 in the PHP.ini inside /PHP
directory,
And I have put Hello.PHP both in the /wwwroot directory and /PHP
directory.
Can you please suggest me what is the problem this time?

Thank you for help!

--Ted

teddybear wrote:
I have replied you on the scripts.com forum. Thanks, and I am looking
forward to your reply!

WhatsPHP wrote:
> This PHP CGI binary was compiled with force-cgi-redirect enabled. This
> means that a page will only be served up if the REDIRECT_STATUS CGI
> variable is set, e.g. via an Apache Action directive.
>
> First thing you need to do is change the line in php.ini so it is
> cgi.force_redirect = Off
>
> Then - and this is where I tore my hair out for a while - if you have
> your php.ini in the /windows directory, ensure there there isn't also a
> default php.ini in the PHP directory as it seems to read that one
> first.
>
> Or, why not just have it in the PHP directory and save a lot of
> heartache :o)


Are you running Apache or IIS?

Apache's home directory is htdocs (usually in the apache/apache2
directory)
IIS uses the inetpub directory as stated by others previously.

Jun 25 '06 #11

P: n/a
william.clarke wrote:
teddybear wrote:
My friend, where are you going? Anybody out there, please help???
I am stuck...

teddybear wrote:
I have another problem now. My browser said "Page Coult Not Be Found".
However I have set cgi.force_redirect = 0 in the PHP.ini inside /PHP
directory,
And I have put Hello.PHP both in the /wwwroot directory and /PHP
directory.
Can you please suggest me what is the problem this time?

Thank you for help!

--Ted

teddybear wrote:

I have replied you on the scripts.com forum. Thanks, and I am looking
forward to your reply!

WhatsPHP wrote:

>This PHP CGI binary was compiled with force-cgi-redirect enabled. This
>means that a page will only be served up if the REDIRECT_STATUS CGI
>variable is set, e.g. via an Apache Action directive.
>
>First thing you need to do is change the line in php.ini so it is
>cgi.force_redirect = Off
>
>Then - and this is where I tore my hair out for a while - if you have
>your php.ini in the /windows directory, ensure there there isn't also a
>default php.ini in the PHP directory as it seems to read that one
>first.
>
>Or, why not just have it in the PHP directory and save a lot of
>heartache :o)

Are you running Apache or IIS?

Apache's home directory is htdocs (usually in the apache/apache2
directory)
IIS uses the inetpub directory as stated by others previously.


The DEFAULT home directory for Apache is htdocs. This can be changed in to any
directory on the system in the httpd.conf file.

Same with IIS - the DEFAULT is inetpub\wwwroot. But can be easily changed.

But in either case PHP can be in its own directory. It does not have to be in
the website path. And the same with php.ini.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 26 '06 #12

P: n/a
Hi,
I run IIS. Can I just email you instead?
Thanks for responding to help.
--Ted

Jerry Stuckle wrote:
william.clarke wrote:
teddybear wrote:
My friend, where are you going? Anybody out there, please help???
I am stuck...

teddybear wrote:

I have another problem now. My browser said "Page Coult Not Be Found".
However I have set cgi.force_redirect = 0 in the PHP.ini inside /PHP
directory,
And I have put Hello.PHP both in the /wwwroot directory and /PHP
directory.
Can you please suggest me what is the problem this time?

Thank you for help!

--Ted

teddybear wrote:

>I have replied you on the scripts.com forum. Thanks, and I am looking
>forward to your reply!
>
>WhatsPHP wrote:
>
>>This PHP CGI binary was compiled with force-cgi-redirect enabled. This
>>means that a page will only be served up if the REDIRECT_STATUS CGI
>>variable is set, e.g. via an Apache Action directive.
>>
>>First thing you need to do is change the line in php.ini so it is
>>cgi.force_redirect = Off
>>
>>Then - and this is where I tore my hair out for a while - if you have
>>your php.ini in the /windows directory, ensure there there isn't also a
>>default php.ini in the PHP directory as it seems to read that one
>>first.
>>
>>Or, why not just have it in the PHP directory and save a lot of
>>heartache :o)

Are you running Apache or IIS?

Apache's home directory is htdocs (usually in the apache/apache2
directory)
IIS uses the inetpub directory as stated by others previously.


The DEFAULT home directory for Apache is htdocs. This can be changed in to any
directory on the system in the httpd.conf file.

Same with IIS - the DEFAULT is inetpub\wwwroot. But can be easily changed.

But in either case PHP can be in its own directory. It does not have to be in
the website path. And the same with php.ini.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================


Jun 26 '06 #13

P: n/a
teddybear wrote:
Hi,
I run IIS. Can I just email you instead?
Thanks for responding to help.
--Ted


Thanks for asking, but no, I keep free support on the newsgroups. That way
everyone can pitch in with their own comments and others can learn from what's
being posted.

I used to provide offline support but it ate into too much of my billable time.
I have to reserve that for my paying customers.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 26 '06 #14

P: n/a
Hi, my question is above...
My browser return error message: "Page Could Not Be Found".
Seems I have done everything installing PHP on IIS.
I have put my hello.php into \wwwroot directory and \PHP directory
I have set the path to c:\PHP
I have change cgi.force_redirect = 0
And still I could not figure out what else to fix.

Well, thanks for your respond, your time and consideration

--Ted

Jerry Stuckle wrote:
teddybear wrote:
Hi,
I run IIS. Can I just email you instead?
Thanks for responding to help.
--Ted


Thanks for asking, but no, I keep free support on the newsgroups. That way
everyone can pitch in with their own comments and others can learn from what's
being posted.

I used to provide offline support but it ate into too much of my billable time.
I have to reserve that for my paying customers.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================


Jun 27 '06 #15

P: n/a
teddybear wrote:
Hi, my question is above...
My browser return error message: "Page Could Not Be Found".
Seems I have done everything installing PHP on IIS.
I have put my hello.php into \wwwroot directory and \PHP directory
I have set the path to c:\PHP
I have change cgi.force_redirect = 0
And still I could not figure out what else to fix.

Well, thanks for your respond, your time and consideration

--Ted


Your files go into the wwwroot hierarchy. C:\PHP is for the php code - not your
web pages.

If you have that in your wwwroot directory and get the not found message when
accessing http://www.example.com/hello.php, you have a setup problem. I suspect
something isn't being loaded properly.

First of all I would highly recommend you install PHP as an isapi filter. It's
not hard - I did it last week in just a little while.

If you're still getting the error, make sure you're using a basic php.ini file -
no extensions, etc. Also, by default the system will try to load the file from
your %SYSTEM_ROOT% directory, so get a copy in there.

If it still fails, please post exactly what you've done to date.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 27 '06 #16

P: n/a
Hi Jerry,
I will try to load ISAPI I will try to follow what you said here and
will come back post the result later.
--Ted

Jerry Stuckle wrote:
teddybear wrote:
Hi, my question is above...
My browser return error message: "Page Could Not Be Found".
Seems I have done everything installing PHP on IIS.
I have put my hello.php into \wwwroot directory and \PHP directory
I have set the path to c:\PHP
I have change cgi.force_redirect = 0
And still I could not figure out what else to fix.

Well, thanks for your respond, your time and consideration

--Ted


Your files go into the wwwroot hierarchy. C:\PHP is for the php code - not your
web pages.

If you have that in your wwwroot directory and get the not found message when
accessing http://www.example.com/hello.php, you have a setup problem. I suspect
something isn't being loaded properly.

First of all I would highly recommend you install PHP as an isapi filter. It's
not hard - I did it last week in just a little while.

If you're still getting the error, make sure you're using a basic php.ini file -
no extensions, etc. Also, by default the system will try to load the file from
your %SYSTEM_ROOT% directory, so get a copy in there.

If it still fails, please post exactly what you've done to date.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================


Jun 27 '06 #17

P: n/a
Hi Jerry,
Just to give you update on my case...
I have solved the problem of "Could Not Find The Page"...
I have tested it with hello.htm. The server IIS is responding. Now the
only thing is
to configure why it does not parse hello.php... it could be the system
recognize it as
hello.php.txt (as it is a text document I created with Text Editor)
Thanks again,
--Ted

teddybear wrote:
Hi Jerry,
I will try to load ISAPI I will try to follow what you said here and
will come back post the result later.
--Ted

Jerry Stuckle wrote:
teddybear wrote:
Hi, my question is above...
My browser return error message: "Page Could Not Be Found".
Seems I have done everything installing PHP on IIS.
I have put my hello.php into \wwwroot directory and \PHP directory
I have set the path to c:\PHP
I have change cgi.force_redirect = 0
And still I could not figure out what else to fix.
>
Well, thanks for your respond, your time and consideration
>
--Ted
>
Your files go into the wwwroot hierarchy. C:\PHP is for the php code - not your
web pages.

If you have that in your wwwroot directory and get the not found message when
accessing http://www.example.com/hello.php, you have a setup problem. I suspect
something isn't being loaded properly.

First of all I would highly recommend you install PHP as an isapi filter. It's
not hard - I did it last week in just a little while.

If you're still getting the error, make sure you're using a basic php.ini file -
no extensions, etc. Also, by default the system will try to load the file from
your %SYSTEM_ROOT% directory, so get a copy in there.

If it still fails, please post exactly what you've done to date.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 2 '06 #18

P: n/a
teddybear wrote:
Hi Jerry,
Just to give you update on my case...
I have solved the problem of "Could Not Find The Page"...
I have tested it with hello.htm. The server IIS is responding. Now the
only thing is
to configure why it does not parse hello.php... it could be the system
recognize it as
hello.php.txt (as it is a text document I created with Text Editor)
Thanks again,
--Ted
No, hello.php.txt will not work. It must have a .php extension.

Apache uses the extension to determine how to route processing. In your Apache
configuration you told it (or at least should have) to parse .php files with the
PHP library. So your files much have .php extensions, not .php.txt or anything
else.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 2 '06 #19

This discussion thread is closed

Replies have been disabled for this discussion.