500 Internal Server Error

This section provides a tutorial on how to troubleshoot the '500 Internal Server Error'. Several common causes of this error are listed.

When you develop and test your Perl scripts with the Apache server, it is quite often that you will get the "500 Internal Server Error" in your browser. The error message says:

Internal Server Error

The server encountered an internal error or misconfiguration and was 
unable to complete your request.

Please contact the server administrator, herong@localhost and inform
them of the time the error occurred, and anything you might have done
that may have caused the error.

More information about this error may be available in the server error

As suggested in the error message, I looked at the error log file located at C:\local\apache\logs\error.log and see several different causes of the "500 Internal Server Error":

1. Missing path name of "perl.exe", #!\local\perl\bin\perl.exe, in the Perl script when the error log file says. The solution is to add the path name prefixed with #! as the first line.

...C:/local/apache/cgi-bin/hello_missing_path.pl is not executable; 
      ensure interpreted scripts have "#!" first line
...(9)Bad file descriptor: don't know how to spawn child process: 

2. Wrong path name of "perl.exe", #!\local\xxx\bin\perl.exe, in the Perl script when the error log file says. The solution is to correct the path name.

...(OS 3)The system cannot find the path specified.  
      : couldn't create child process: 720003: hello_wrong_path.pl
...(OS 3)The system cannot find the path specified.  
      : couldn't spawn child process: C:/local/apache/cgi-bin/hell...

3. Wrong option for "perl.exe", #!\local\perl\bin\perl.exe -bad, in the Perl script when the error log file says. The solution is to remove or correct options after the path name.

...Premature end of script headers: hello_wrong_option.pl
...Unrecognized switch: -bad  (-h will show valid options).\r

The picture below shows you how the "500 Internal Server Error" is displayed in the browser.
Apache 2.2 - 500 Internal Server Error

Last update: 2014.

Table of Contents

 About This Book

 Perl on Linux Systems

 ActivePerl on Windows Systems

 Data Types: Values and Variables

 Expressions, Operations and Simple Statements

 User Defined Subroutines

 Perl Built-in Debugger

 Name Spaces and Perl Module Files

 Symbolic (or Soft) References

 Hard References - Addresses of Memory Objects

 Objects (or References) and Classes (or Packages)

 Typeglob and Importing Identifiers from Other Packages

 String Built-in Functions and Performance

 File Handles and Data Input/Output

 Open Files in Binary Mode

 Open Directories and Read File Names

 File System Functions and Operations

 Converting Perl Script to Executable Binary

 Using DBM Database Files

 Using MySQL Database Server

 Socket Communication Over the Internet

 XML::Simple Module - XML Parser and Generator

 XML Communication Model

 SOAP::Lite - SOAP Server-Client Communication Module

 Perl Programs as IIS Server CGI Scripts

 CGI (Common Gateway Interface)

 XML-RPC - Remote Procedure Call with XML and HTTP

 RPC::XML - Perl Implementation of XML-RPC

Integrating Perl with Apache Web Server

 Downloading Apache HTTP Server 2.2.25 for Windows

 Installing Apache HTTP Server 2.2.25 on Windows

 Publishing HTML Documents as Web Pages

 Starting and Stopping Apache Server

 Running Perl Scripts in "cgi-bin"

 printenv.pl - Testing Perl CGI Environment

500 Internal Server Error

 cgi-lib.pl - The Standard Library for CGI Scripts

 ReadParse() - Parsing Web Form Input Values

 Running Perl Scripts in "htdocs"

 CGI.pm Module for Building Web Pages

 LWP::UserAgent and Web Site Testing


 PDF Printing Version