Web Servers on Unix and Linux - Not sure if this is the right place, but maybe you could redirect me.

This is Interesting: Free IT Magazines  
Home > Archive > Web Servers on Unix and Linux > April 2004 > Not sure if this is the right place, but maybe you could redirect me.





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Not sure if this is the right place, but maybe you could redirect me.
Egomaniac

2004-04-11, 4:31 pm

Greetings,

Please copy all replies to my email addy: mail to:
egomaniac1992@hotmail.com.

I'm running:
apache 1.3.29
php 4.3.4
mod_perl 1.20
openssl 0.9.7c
mm 1.3.0
mod_ssl 2-8.16-1.3.29
cgiwrap 3.24
Apache::ASP

I am trying to run a file called add.php out of my /cgi-bin/. To make
sure everything else was setup correctly, I tried the following:

a) Does a .asp file run out of the cgi-bin?
with the following action attribute for my form:
<form action="/cgi-bin/time.asp" method="post">
(time.asp is a simple script that dynamically prints
out the time.
* this works as expected. Time shows up on the page delivered to
the browsing client.

b) Does mod_perl work?
with the following action attribute for my form:
<form action="/perl/test.pl" method="post">
(test.pl is a simple script that will print out "Hello World"
to a browser.

* This works as expected - Hello World is outputted to the client

c) Does a .php script work?
with the following action attribute for my form:
<form action="/cgi-bin/test.php" method="post">
(test.php is a simple script that executes a php_info();
function to the browser. Here it is:

test.php
<html>
<head></head>
<body>
<h1>This is a test</h1>
<?php
print "Content-Type: text/html\n\n";
phpinfo();
?>
</body>
</html>

(I tried outputting correct headers in any way possible
to see where things could be going wrong)

This script bombs with an internal server error.
A look at error_log gives the above message:
[Sun Apr 11 14:55:22 2004] [error] [client 127.0.0.1]
Premature end of script headers: /www/cgi-bin/test.php

Trouble Shooting
----------------

I've looked at the following things:

First, lets see if the Command Line Interpreter can parse and execute
the file:
/usr/local/bin/php /www/cgi-bin/test.php
(without pasting the output, it worked as expected:
a dump of html with php config options)

My httpd.conf file
AddType application/x-httpd-php .php
AddType application/x-httpd-php .php4
AddType application/x-httpd-php .phtml

Note: I don't have a LoadModule, AddModule directive, since
I've compiled the php4 binary in with apache.
An httpd -l will show the story:
http_core.c
mod_php4.c
mod_env.c
mod_log_config.c
mod_mime.c
mod_negotiation.c
mod_status.c
mod_include.c
mod_autoindex.c
mod_dir.c
mod_cgi.c
mod_asis.c
mod_imap.c
mod_actions.c
mod_userdir.c
mod_alias.c
mod_access.c
mod_auth.c
mod_so.c
mod_setenvif.c
mod_ssl.c
mod_php4.c
mod_perl.c

Why mod_php4.c shows up twice, though, is something I don't
quite get...maybe someone here has an answer?
But, you get the picture, it's installed in the httpd binary.

Will .php files be recognized out of the Document Root directory.
a) I put a copy of test.php in my htdocs dir.
One would expect the browser to recognize the file as
a .php file (thanks to the AddTypes) and serve it up.

** This happens as expected.

So, the bottom line looks like my .php files won't run out of
/cgi-bin
but will run out of htdocs dir.

Any help here would be appreciated. I'm all out of ideas.
Owen Jacobson

2004-04-11, 9:43 pm

On Sun, 11 Apr 2004 13:12:34 -0700, Egomaniac wrote:

> I am trying to run a file called add.php out of my /cgi-bin/. To make
> sure everything else was setup correctly, I tried the following:
>
> c) Does a .php script work?
> with the following action attribute for my form:
> <form action="/cgi-bin/test.php" method="post">
> (test.php is a simple script that executes a php_info();
> function to the browser. Here it is:
>
> This script bombs with an internal server error.
> A look at error_log gives the above message:
> [Sun Apr 11 14:55:22 2004] [error] [client 127.0.0.1]
> Premature end of script headers: /www/cgi-bin/test.php
>
> So, the bottom line looks like my .php files won't run out of
> /cgi-bin
> but will run out of htdocs dir.


This is correct, given the configuration you quoted. (a) what are you
trying to accomplish, and (b) have you tried adding

#!/usr/local/bin/php

as the *first* line of the script?

--
Some say the Wired doesn't have political borders like the real world,
but there are far too many nonsense-spouting anarchists or idiots who
think that pranks are a revolution.

Egomaniac

2004-04-14, 3:38 pm

Owen Jacobson <angstrom@lionsanctuary.net> wrote in message news:<pan.2004.04.12.01.24.35.105706@lionsanctuary.net>...
> On Sun, 11 Apr 2004 13:12:34 -0700, Egomaniac wrote:
>
>
> This is correct, given the configuration you quoted. (a) what are you
> trying to accomplish, and (b) have you tried adding
>
> #!/usr/local/bin/php
>
> as the *first* line of the script?


Thanks for the help.

Ok, fair enough.

a) What I will eventually want this script to do, is take
my magic card information (per card) and store that information in
a
database.
For now, though, I'm just trying to get a basic .php
script to output phpinfo() to a browser.

b) Ok, fair enough again. I've added the
#!/usr/local/bin/php to the top of the script.

It now looks like this:
#!/usr/ocal/bin/php
phpinfo();


The output I get is - again - not what's expected:

With a form action syntax like this:
<form action="/cgi-bin/test.php" method="post">

I still get an internal server error.
The error_log file looks like this:

[Tue Apr 13 10:53:26 2004] [error] (2)No such file or directory:
exec of /www/cgi-bin/test.php failed

[Tue Apr 13 10:53:26 2004] [error] [client 127.0.0.1] Premature end
of script headers: /www/cgi-bin/test.php


I'm a bit lost, any help appreciated.
Egomaniac

2004-04-14, 3:38 pm

Owen Jacobson <angstrom@lionsanctuary.net> wrote in message news:<pan.2004.04.12.01.24.35.105706@lionsanctuary.net>...
> On Sun, 11 Apr 2004 13:12:34 -0700, Egomaniac wrote:
>
>
> This is correct, given the configuration you quoted. (a) what are you
> trying to accomplish, and (b) have you tried adding
>
> #!/usr/local/bin/php
>
> as the *first* line of the script?


Thanks for the help.

Ok, fair enough.

a) What I will eventually want this script to do, is take
my magic card information (per card) and store that information in
a
database.
For now, though, I'm just trying to get a basic .php
script to output phpinfo() to a browser.

b) Ok, fair enough again. I've added the
#!/usr/local/bin/php to the top of the script.

It now looks like this:
#!/usr/ocal/bin/php
phpinfo();


The output I get is - again - not what's expected:

With a form action syntax like this:
<form action="/cgi-bin/test.php" method="post">

I still get an internal server error.
The error_log file looks like this:

[Tue Apr 13 10:53:26 2004] [error] (2)No such file or directory:
exec of /www/cgi-bin/test.php failed

[Tue Apr 13 10:53:26 2004] [error] [client 127.0.0.1] Premature end
of script headers: /www/cgi-bin/test.php


I'm a bit lost, any help appreciated.
Owen Jacobson

2004-04-14, 3:38 pm

On Tue, 13 Apr 2004 09:08:03 -0700, Egomaniac wrote:

> I still get an internal server error.
> The error_log file looks like this:
>
> [Tue Apr 13 10:53:26 2004] [error] (2)No such file or directory:
> exec of /www/cgi-bin/test.php failed
>
> [Tue Apr 13 10:53:26 2004] [error] [client 127.0.0.1] Premature end
> of script headers: /www/cgi-bin/test.php
>
>
> I'm a bit lost, any help appreciated.


One:

$ ls -l | grep test.php
-rwxr-xr-x 1 owen owen 33 Apr 13 17:41 test.php
^ ^ ^ check the permissions

Two: can you run the script like this, rather than explicitly invoking
php? If not, what error do you get from the shell?

$ ./test.php
X-Powered-By: PHP/4.2.2
Content-type: text/html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
.....

Three:

Why are you using php from a ScriptAlias directory and not, say, anywhere
you want (which would obviate the permissions issue and the shabang)? PHP
is designed to be integrated anywhere in the site that the appropriate
types are present, which from your config sounds like "everywhere".

--
Some say the Wired doesn't have political borders like the real world,
but there are far too many nonsense-spouting anarchists or idiots who
think that pranks are a revolution.

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com