perlcgi-bin

Apache Perl 500 “Internal Server Error” - malformed header from script. Bad header=<!DOCTYPE html>


I'm getting an Apache "500 Internal Server Error" even after installing Perl. Running the file from the terminal works fine (perl hello.pl).

Perl Mod setup with Apache everything is configured correctly (chmod the file etc).

#!/usr/bin/perl
print("Hello, World!\n");

I am still getting a 500 server error.


Solution

  • I checked the apache_error.log and saw

    malformed header from script. Bad header=<!DOCTYPE html>
    

    You need to add a Content-type Header to the file.

    Fix

    #!/usr/bin/perl
    print "Content-type: text/html\n\n";
    print("Hello, World!\n");