CGI-BIN giving 500 errors

WebXplosion

Verified User
Joined
Sep 15, 2005
Messages
15
Hi there,

I've been trying to install AWStats all day, but I'm stuck at the perl script. For some reason NO perl or cgi script will run through http on my server.

I've tried a test.pl with only the following contents;
PHP:
#!/usr/bin/perl
print "Hello, you!";

And even that will return the 500.
CHMOD at 755.

The file will run fine in SSH and the syntax is good too.
No weird linebreaks or anything!

SUEXEC_LOG:
PHP:
[2006-04-11 16:32:15]: info: (target/actual) uid: (admin/admin) gid: (admin/admin) cmd: test.pl

The user permissions are also correct.
I've gone through like 10 threads but nothing works for me.

Any help at all would be greatly appreciated!
 
Have you had any luck with solving this?

I have the same problem myself (just on the perl scripts.. nothing awstats related.. though i'm sure thats dead to.)

Permissions fine. running via SSH works fine.

Just the same message as you

Cheers

Brendon
 
Hello,

You're missing your headers ;)
PHP:
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "Hello, you!";
John
 
Ok that worked.. on my test script (YAY!)

So how do i get it to work for all cgi /pl files

It's been driving me nuts.

Is there a setting (sounds mime-ish ) that will do this?

Cheers

Brendon
 
Hello,

If these files were ever edited on windows, they'll end up with a strange newline character that unix doesn't like... edited in nano/pico it looks like ^M ... to get rid of it, edit the files in the DA file editor and save the file. The editor trims them out automatically.

Related guide:
http://help.directadmin.com/item.php?id=6

John
 
Actually it seems to work..

i think now maybe i spend so long testing the hello world test script (which didn't have the headers) that i never noticed i actually fixed the real problem.
 
Doesn't work for me :(
I've even tried creating the file in SSH with Vi, and then setting the permissions back, but nogo :(
 
More info please ;)

"perl does not work"... do you mean the cgi files, or perl itself? What are you seeing that lets you know it's not working? What errors? Try this guide:
http://help.directadmin.com/item.php?id=6

Try running the cgi's manually.
Check the /var/log/httpd/suexec_log to see if they're being run or not.

Set everything to 755, and make sure the owner of everything is the same as your DA user.

John
 
Well read above, the same problems :)

- perl itself works properly
- the script works when I run it through SSH
- permissions are correct
- chmod is correct
- suexec returns this:
Code:
[2006-04-21 00:31:11]: info: (target/actual) uid: (admin/admin) gid: (admin/admin) cmd: test.pl

While I restart apache now, I get this:
Code:
Starting httpd: [Fri Apr 21 00:45:47 2006] [warn] module perl_module is already loaded, skipping

And then apache loads fine, but the script won't work :P
 
What do you see in apache? (in your web browser)

Also paste usthe output of:
Code:
cd /path/to/cgi-bin
./test.pl | head -n 6
So that we can take a look at the headers it's spitting out. They may be weird... really not sure at this point.

John
 
Damn you're fast and thanks for that :P

My browser returns "internal server error" (500)

And the headers;
Code:
[root@webxplosion cgi-bin]# ./test.pl | head -n 6
Hello, you!

Weird innit?
I saw some line about perl while building apache a few minutes ago, but I couldnt read what it was exactly, would there be a log of this rebuild perhaps? :P
 
Hello,

Ok, you're missing you're "headers".

With cgi scripts, you have full control over the output to the web browser. WIth httpd, you have *have* to send your headers, followed by 2 newlines, and only then can you output your script's code.
PHP:
#!/usr/bin/perl
print "Hello, you!";
Will *not* work.

If you change it to this, as mentioned above, it will:
PHP:
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "Hello, you!";
John
 
Wow :eek:
That works, thanks John!

Now, what started all this trouble is awstats.
Since they are running from outside the cgi-bin, and with root permissions, the awstats.pl script (to display the stats from www) would not work.

I've chowned and chmodded this, and now it runs, but it won't display my stats :P
I'm guessing because it's not allowed to access the stats file located in /var/lib/awstats which is owned by root?

chowning that won't work either, so once again I am puzzled :P
And I'm gonna try the plugin now, see how that works out.
 
Back
Top