Friday, June 22, 2012

How to Enable Apache2 webserver with CGI and Perl Support in Ubuntu Server

mkdir /home/www/cgi-bin




ScriptAlias /cgi-bin/ /home/www/cgi-bin/

Options ExecCGI
AddHandler cgi-script cgi pl

apache2ctl restart

Test your Perl Program
cd /home/www/cgi-bin

edit first.cgi

#!/usr/bin/perl -wT
print "Content-type: text/html\n\n";
print "Hello, world!\n";
chmod a+x first.cgi
open your web browser open http://yourserverip/cgi-bin/first.cgi
.It should be working. 

edit second.cgi

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

Hello, world!

\n"; print "\n";

No comments: