Perl and usr/bin

7 posts / 0 new
Last post
#1 Tue, 06/24/2008 - 05:23
eboughey

Perl and usr/bin

I've got a cgi script but I keep getting a 500 internal server error.

I don't see #!/usr/bin/perl which it has as the location for perl.

Any help on what the rules are for setting up cgi and pointing to perl would be much appreciated.

Tue, 06/24/2008 - 05:59
andreychek

Well, assuming your Perl script is using CGI (rather than mod_perl), the path to Perl at the top of the script would need to exist. Even if you are using mod_perl, it can't hurt to have the right path ;-)

So if your Perl binary were in /usr/bin/perl, the script would need #!/usr/bin/perl. If you type 'which perl', that should give you a hint as to where the Perl binary is.

But, anytime you see "500 Internal Server Error", you'll often get a helpful error message in the Apache error log, which might help to point you in the right direction.
-Eric

Tue, 06/24/2008 - 09:04
eboughey

Now for my second newbie question (and I've been on the system for almost a year...)

Terminal command 'which perl' says usr/bin/perl so that's okay

The error log says 'script not found or unable to stat' (yes, stat not start).

When I tried the test cgi it says 'premature end of script headers'

How can i tell if cgi is enabled?

Tue, 06/24/2008 - 09:17 (Reply to #3)
andreychek

What is the output of the following command:

ls -l /path/to/your/script.pl

I'm curious if there's some form of permissions issue.
-Eric

Tue, 06/24/2008 - 09:29
eboughey

Here are the permissions

ls -l /home/ekmb/public_html/cgi-bin
total 20
drwxr-xr-x 2 ekmb ekmb 4096 Jun 24 14:46 data
drwxr-xr-x 3 ekmb ekmb 4096 Jun 24 14:46 html
-rwxr-xr-x 1 ekmb ekmb 4643 Jun 24 14:46 search.cgi
-rwxr-xr-x 1 ekmb ekmb 1398 Jun 24 14:46 test1234.cgi

Tue, 06/24/2008 - 09:37 (Reply to #5)
Joe
Joe's picture

That's not a working cgi-bin path on Virtualmin. Scripts would execute from /home/ekmb/cgi-bin on Virtualmin systems (you could configure it to execute the way you've set it up, but I wouldn't recommend it--the way security is sometimes implemented in CGI scripts is somewhat different than the way PHP scripts are setup, and so having the cgi-bin within a normal document root can lead to unexpected data exposure).

--

Check out the forum guidelines!

Wed, 06/25/2008 - 04:49 (Reply to #6)
sgrayban

The default template location for cgi-bin is /home/domain/cgi-bin/ NOT /home/domain/public_html/cgi-bin/

Scripts should always be located *outside* the web doc root for security.

Topic locked