Ref: http://httpd.apache.org/docs/2.0/howto/cgi.html
If you want to run a perl script like this http://www.mydomain.com/test.pl , you will have to to define explicitly use the Options directive, inside your main server configuration file, to specify that CGI execution was permitted in a particular directory:
Example:
<VirtualHost *:80>
ServerAdmin adin@mydomain.co.uk
DocumentRoot /var/www/html/mydomain/
ServerName mydomain.co.uk
ServerName www.mydomain.co.uk
ErrorLog logs/mydomain.co.uk-error_log
CustomLog logs/mydomain.co.uk-access_log common
<Directory “/var/www/html/mydomain/”>
Options FollowSymLinks ExecCGI
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
The above directive tells Apache to permit the execution of CGI files.
You will also need to tell the server what files are CGI files. The following AddHandler directive tells the server to treat all files with the cgi or pl extension as CGI programs:
AddHandler cgi-script .cgi .pl
Now Save the configuration file and Restart apache.