Configuring Apace Server to run PERL scripts

Follow following steps to run PERL script on Apace Server

Step 1: 
Open <APACHE_HOME>/conf/httpd.conf file

httpd.conf - is the main configuration file for Apache HTTP Server

Step 2: 
Search for "ScriptAlias /cgi-bin/" uncomment i.e. remove '#' if commented. You may need to adjust the path to run your script successfully

ScriptAlias - Provides the location for CGI programs. This should be two parts, separated by whitespace. The first part is the part used in URL that triggers execution of a CGI program; the second part is the path where those CGI programs are stored in the real filesystem

Step 3:
Search for "AddHandler cgi-script" in the document, uncomment it, if committed and append ".pl " after ".cgi"

Step 4: 
Modify your PERL Script. If your script is Windows executable it does't means that it will run on Apache Server as well 'coz script relies on PERL interpreter, so we have to modify the hashbang or the shebang or  the first line of your script. Append perl.exe (For Windows only)

Step 5: 
The line after shebang line should define the MIME-type header.

print "Content-type: text/html; charset=iso-8859-1\n\n"; 

Now you are all set to run your first CGI program. Just open your browser and access http://localhost/cgi-bin/

NOTE: is the name of the PERL file I created it can be different in your case.



Popular posts from this blog

Using Solr Spellchecker from Java

Importing / Indexing MySQL data into Solr

Custom PagingNavigator for SEO friendly URL