Software Development, Tomcat

CGI with Tomcat 8

This shows how to configure Apache Tomcat 8 for CGI.

Software Environment

These are the items we used for this post.

  • Windows 7 Professional SP1
  • Any web browser
  • Apache Tomcat 8.0.14
  • ActivePerl 5.16.3.1604 (Windows x86)
  • Java 1.7 (1.7.0_67 – Windows x86)

Install Java SE Development Kit 7

The first thing we need to do is install Java in Windows 7. Here are the steps on how to perform the installation.

First, download Java SE Development Kit 7 from Oracle.

Second, install Java SE Developer Kit 7.

Finally, verify the installation.

01-cgi-with-tomcat-8

Install ActivePerl For CGI Script

First, download ActivePerl from www.activestate.com.

Then, install ActivePerl.

Next, append the c:\<PERL HOME>\bin to %PATH%. We can do the last step either on the command line to invoke Tomcat start.bat or System Properties -> Advanced tab -> Environment Variables -> PATH.

Finally, verify the installation.

Download and Extract Apache Tomcat 8

First, download Apache Tomcat from www.apache.org. Then, choose “zip” from Core on the Binary Distributions section.

09-cgi-with-tomcat-8

Next, extract the archive to any directory

Configure Apache Tomcat to enable CGI

First, modify <SOMEWHERE>/apache-tomcat-8.0.14/conf/web.xml by uncommenting the whole cgi <servlet> tag and adding passShellEnvironment = true init-param.

Then, modify <SOMEWHERE>/apache-tomcat-8.0.14/conf/context.xml by adding a privileged attribute and setting its value to true.

Next, create a “cgi” directory under <SOMEWHERE>/apache-tomcat-8.0.14/webapps/ROOT/WEB-INF. Fourth, create a .cgi script under <SOMEWHERE>/apache-tomcat-8.0.14/webapps/ROOT/WEB-INF/cgi

Then, start Tomcat 8 up.

Finally, access http://localhost:8080/cgi-bin/test1.cgi

10-cgi-with-tomcat-8

Tomcat 7

To configure Tomcat 7 for CGI, read the following post.

CGI with Tomcat 7

Got comments or suggestions? We disabled the comments on this site to fight off spammers, but you can still contact us via our Facebook page!.


You Might Also Like