Forum Moderators: coopster & phranque

Message Too Old, No Replies

I can't run any pl script from browser

         

jastog

9:16 am on Mar 18, 2004 (gmt 0)

10+ Year Member



Hi there.
I can't run any pl script from web browser (always: 500 Internal Server Error even for "Hello World").
I searched lot of forums, but no solution matched my problem. I chmod all posibille combination (from home to the script it self (in /home/foo/cgi-bin/). No use.
What is installed:
RH 9.0
Apche 2.048 with suexec (i think here is problem) runned as nobody/nobody ( i put "SuexecUserGroup foo foo" in conf file).
Perl 5.8...
Mod_Perl 1.99
All scripts can be runned from command line, but none from browser.
Plese help.

jastog

9:18 am on Mar 18, 2004 (gmt 0)

10+ Year Member



I forgot to add, apche, perl and mod perl are installed form source (i dont't use any stupid rpm's)
and error log is:Premature end of script headers

SeanW

2:04 pm on Mar 18, 2004 (gmt 0)

10+ Year Member



"Premature end of script headers" usually means you either forgot to push out a Content-type header, or the script had some errors. The former is easy enough to check from the command line, the latter will show up in the error log.

Sean

jastog

2:32 pm on Mar 18, 2004 (gmt 0)

10+ Year Member



here is an sample script:

--------------------
#!/usr/bin/perl

#
print "Content-type: text/html\n\n
<HEAD>
<TITLE>Hello</TITLE>
</HEAD>
<BODY>
<HR>
<H1>Hello!</H1>
<HR>
</BODY>
";
---------------
It returns 500 Internal Server Error, and again, it works if i run it from command line.

Suexec error:

[2004-03-18 17:34:14]: uid: (****/xxx) gid: (xxx/xxx) cmd: hello.pl
[2004-03-18 17:34:14]: command not in docroot (/home/foo/cgi-bin/hello.pl)

Hissingsid

8:17 pm on Mar 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi,

The syntax of your little script passes my syntax checker. It runs just fine here also from my browser.

I would get hold of PerlDiver.cgi (or .pl) and see if that runs on your server.

Also try putting this into your script after the shebang

use CGI::Carp qw(fatalsToBrowser);

Hopefully CGI::Carp will be on your server and you will see some meaningfull error messages in your browser. If you do use this I would ##comment it out.

I'm not smart enough to be able to decifer your log but here are few things to check:

Make sure you are uploading as ASCII text not binary. If you are working on a non (U)nix platform make sure the line endings are of the Unix variety in your form. Pre OS X Mac is particularly bad in this regard.

Also check that the server allows the .pl extension. Mine currently only allows .cgi to run.

I hope that this helps.

Best wishes

Sid

ebizcamp

12:50 am on Mar 19, 2004 (gmt 0)

10+ Year Member



#!/usr/bin/perl 

#
print "Content-type: text/html\n\n
<HEAD>
<TITLE>Hello</TITLE>
</HEAD>
<BODY>
<HR>
<H1>Hello!</H1>
<HR>
</BODY>
";

Special characters should be escaped. <\/title>

SeanW

1:01 am on Mar 19, 2004 (gmt 0)

10+ Year Member




command not in docroot (/home/foo/cgi-bin/hello.pl)

I don't think we're dealing with a perl problem here... It looks like a setup problem. Does your webhost provide any instructions for using CGI?

Sean

moltar

2:11 am on Mar 19, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



SuExec is evil.

What is your control panel setup? I just had a similar problem on Plesk.

jastog

8:17 am on Mar 19, 2004 (gmt 0)

10+ Year Member



It was suexec. I had to recompaile apacehe with --with-suexec-docroot=/home. This allowes Mr. foo to execute scripts only in this path (not just his own home dir /home/foo/), but only if you use SuexecUeserGroup in conf for apache or if you dont use apache can execute scripts inside this path.
This was the basic problem (and finaly "Hello" was in my browser). Now i am run into another problem. Another script(s) returns Internal server error, with "failed to open log file; fopen: Permission denied in script error log. Suexec log is OK, with no errors.
So I have to topics to discuss:
1. Why Apache dont have Suexec separate rules for vhosts, e.g. it can use DocumentRoot in Vhost definiton instead using single and general DocumentRoot for suexec (defined during compilation) for all vhosts.
2. How to solve my problem with "fopen" (script works from command prompt)