Skip to main content
  1. Posts/

Enabling CGI in Apache virtual hosts

·64 words·1 min·

Add this to the Apache configuration:

ScriptAlias /cgi-bin/ "/var/www/html/cgi-bin/"
<Directory "/var/www/html/cgi-bin">
        Options +ExecCGI
        AddHandler cgi-script .cgi

Reload Apache and throw this in as test.cgi into your cgi-bin directory:

print "Content-type: text/html\n\n";
print "Hello, World.";

Do not omit the content-type on your perl scripts. If you do, Apache will throw a random 500 Internal Server Error and it won’t log anything about it.