7-steps-to-configure-tomcat-for-cgi-perl




Configuring CGI  Perl in Apache Tomcat :

Software Requirement:

  • Apache Tomcat 7.0.11 or above
  • JDK 1.6 or above
  • Perl 5 or above
  1. Download Tomcat. Install or unzip it to some directory.
  2. Modify <TOMCAT_HOME>/conf/web.xml to uncomment the cgi servlet and its mapping

 

 
<servlet>
 <servlet-name>cgi</servlet-name>
 <servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class>
 <init-param>
 <param-name>debug</param-name>
 <param-value>0</param-value>
 </init-param>
 <init-param>
 <param-name>cgiPathPrefix</param-name>
 <param-value>WEB-INF/cgi</param-value>
 </init-param>
 <init-param>
 
add the following:

<init-param

<param-name>passShellEnvironment</param-name>

 <param-value>true</param-value>
 </init-param>
 
now the CGI blocks look like:
 
 
<servlet>
 <servlet-name>cgi</servlet-name>
 <servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class>
 <init-param>
 <param-name>debug</param-name>
 <param-value>0</param-value>
 </init-param>
 <init-param>
 <param-name>cgiPathPrefix</param-name>
 <param-value>WEB-INF/cgi</param-value>
 </init-param>
 <init-param>
 <param-name>passShellEnvironment</param-name>
 <param-value>true</param-value>
 </init-param>
 <load-on-startup>5</load-on-startup>
</servlet>
 
3: Modify the servlet-mapping 
 
<servlet-mapping>
 <servlet-name>cgi</servlet-name>
 <url-pattern>/cgi-bin/*</url-pattern>
</servlet-mapping>
 
 
4:Modify <TOMCAT_HOME>\conf\context.xml to add a property on <Context>: 

 




<Context privileged="true">
...
</Context>
 
5.Create a cgi folder under <TOMCAT_HOME>/webapps/ROOT/WEB-INF/
 
mkdir <TOMCAT_HOME>/webapps/ROOT/WEB-INF/cgi
 
6. Create the CGI or Pl file under the same directory 
 

 <TOMCAT_HOME>/webapps/ROOT/WEB-INF/cgi/test.cgi




 
#!C:\Perl\bin\perl.exe
# filename: test1.cgi
print"Content-type: text/html\n\n";
print"Hello, world!\n"
 
7. Restart the Apache server
 

                     Android Not getting Detected in Ubuntu Systems

 

Related

Leave a Reply

Your email address will not be published. Required fields are marked *

Translate »
[huge_it_videogallery id="2"]
Close