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

329 Views Asked by At

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.

1

There are 1 best solutions below

0
K-G On BEST ANSWER

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");