Configuring CGI Perl in Apache Tomcat :
Software Requirement:
Software Requirement:
- Apache Tomcat 7.0.11 or above
- JDK 1.6 or above
- Perl 5 or above
- Download Tomcat. Install or unzip it to some directory.
- 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.cgiprint "Content-type: text/html\n\n";print "Hello, world!\n" 7. Restart the Apache server 8: Open the link:http://localhost:8080/cgi-bin/test.cgi 
World's Best Blog...This guy is a champ... Expert in perl...May he live long
ReplyDeleteGood Work!!
ReplyDeleteYour blogs have always helped me, whenever I get struck at any point in configuration.
Keep sharing your experiences.