0

CGI with Tomcat 8

Background

This article demonstrates how to configure Apache Tomcate 8 for CGI.

Hardware Environment

n/a

Software Environment

  • 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

1. Download Java SE Development Kit 7 from Oracle

2. Install Java SE Developer Kit 7

3. Verify installation

01-cgi-with-tomcat-8

Install ActivePerl

1. Download ActivePerl from www.activestate.com

2. Install ActivePerl

3. Append the c:\<PERL HOME>\bin to %PATH%

This can be done either on the command line where you would also invoke Tomcat start.bar or System Properties -> Advanced tab -> Environment Variables -> PATH

3. Verify installation

08-cgi-with-tomcat-8

Download and Extract Apache Tomcat 8

1. Download Apache Tomcat 8 from www.apache.org

Choose “zip” from Core on the Binary Distributions section.

09-cgi-with-tomcat-8

2. Extract the archive to any directory

Configure Apache Tomcat 8 to enable CGI

1. Modify <SOMEWHERE>/apache-tomcat-8.0.14/conf/web.xml uncommented the whole cgi <servlet> tag and adding passShellEnvironment = true init-param.

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

3. Create a “cgi” directory under <SOMEWHERE>/apache-tomcat-8.0.14/webapps/ROOT/WEB-INF

4. Create a .cgi script under <SOMEWHERE>/apache-tomcat-8.0.14/webapps/ROOT/WEB-INF/cgi

5. Start Tomcat

6. Access http://localhost:8080/cgi-bin/test1.cgi

10-cgi-with-tomcat-8