Thursday, November 25, 2010

How to add Perl-CGI support to your apache web server in Ubuntu

So I assume you've installed Apache(if not then click here to see how) and now you want to run some CGI scripts written in Perl. What I'm going to describe here is only a simple way of executing CGI Scripts. This has some serious security flaws and a pro may just break it in seconds. So if you're a network administrator trying to implement something for your server then this is definitely not where you should be.

I assume you've installed apache using the command "sudo apt-get install apache2".

Next thing you got to install is  this library module that links your webserver with the perl engine.
sudo apt-get install libapache2-mod-perl2
Now you're ready to go. You must use this in your browser :
http://localhost/cgi-bin/programname.cgi

The CGI file programname.cgi is present in directory /usr/lib/cgi-bin/.

It is convenient to have a symbolic link to the cgi-bin directory from your /var/www/ directory. You can create one using the following command.

ln -s /usr/lib/cgi-bin/
Make sure the program has all the required permission.

No comments:

Post a Comment