Wednesday 6 March 2013

Simple Perl and CGI example

This is probably the simplest possible example to get Perl working through cgi on Apache HTTPD. Instructions are for Ubuntu 12.04.

Install apache httpd:

sudo apt-get install apache2

Add the following "hello.pl" script to the /usr/lib/cgi-bin directory:

#!/usr/bin/perl

print "Content-type: text/html\n\n";
print "Hello World!";
exit;

Point your browser at http://localhost/cgi-bin/hello.pl and that's it!

No comments: