Easiest way to configure Perl/Python with CGI of apache

Most of the cases you have to modify few configuration file from apache when you need to setup your CGI for Perl Python scripting languages. I found an easiest way to configure the CGI. You won't need to modify any file. Just follow the below steps.

** Download the latest version of EasyPHP(EasyPHP 2.0b1 from http://www.softpedia.com/get/Authoring-tools/Setup-creators/EasyPHP.shtml) and install it.

** Inside the installation directory you'll fine a folder "cgi-bin". Just put your cgi scripts there and browse them from browser.

1) For example you have written a CGI script using Perl script. Lets say the below code.

#!c:/Perl/bin/perl.exe

use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);

## type of content at web browser
print "Content-type: text/plain\n\n";

## Your perl code will be here.
print "Perl/CGI working successfully!!!\n";

Put the script into the "cgi-bin" folder and browse it from browser as http://127.0.0.1/cgi-bin/helo.pl. Remember The first line of the CGI script defines the path to Perl.exe file. It may change depends upon your Perl installation directory. Change accordingly.

2) Now you have written a CGI script using Python script. Lets say the below code.

#!c:/Python25/python.exe

## type of content at web browser
print "Content-type: text/plain\n\n"

## Your python code will be here
print "Python/CGI working successfully!!!\n"

Put the script into the "cgi-bin" folder and browse it from browser as http://127.0.0.1/cgi-bin/helo.py. Remember The first line of the CGI script defines the path to Python.exe file. It may change depends upon your Python installation directory. Change accordingly.

You can make sub directory inside the "cgi-bin" folder and can browse them using the sub directory. For example

http://127.0.0.1/cgi-bin/sub1/sub2/sub3/helo.pl

I have posted another topic related to EasyPHP and php+curl at http://icfun.blogspot.com/2008/04/configure-php-curl-with-apache.html. If you are interested you can view the post.

Comments

Anonymous said…
Man, thank you very much, i was going mad with this, and the solution was simple and obvious.