[ back to toc ]

server error - perl

Date: 2002/03/02 20:07

I am trying to get my perl script working and Apache is giving me a 500
server error. I am fairly new to apache and perl.

By definition 500 means internal server error. In your case internal also
means an error in the script. This error comes up from Apache if there is
some error in the script. This can also happen if the script works, but
does not send correct header, like

Status: 200
Content-Type: text/html

You can do the following:

1. Check from the command line that the script is syntax error free.
Use -w option of Perl

2. Check the file permissions. The web serveruser is nobody or www-data.
Set the permission of the script to

chmod 777 script.pl

If the script works after that then the issue is permission. However this
is NOT solved yet! The permission setting 777 is unsecure. Do not leave it
like that! Alter the permission to the most secure. Consult the man chmod.

However permission issues usually do not produce 500 error.

3. Check that the script starts with the appropriate

#! /usr/bin/perl

and that the interpreter is really there. Start

/usr/bin/perl -V

to see the version of Perl. It should be 5.0 or later.

The path can also be /usr/local/bin/perl but eventually can be anything

check that the Perl interpreter itself is executabvle by the web server

4. Alter the script putting

print "Status: 200 OK\nContent-Type: text/html\n\n";

immediately after the first line.


[ back to toc ]