
Configuring a Webapp in Apache Tomcat and Serving It via Httpd
A step-by-step guide to configuring a JSP webapp with Apache Tomcat and Httpd.
Contents
Migrating an old JSP project to a new server recently got me to spend some time with Apache Tomcat and document the configuration. The starting point was a JSP application (webapp) that was to be served through an existing Apache HTTPd web server.
The following description refers to a Windows Server, but it should be just as easy to implement on Linux.
Preparation
- Create the application directory D:\Websites\www.domain.at\webapps.
- Create the log directory D:\Websites\www.domain.at\logs.
- Create the Tomcat configuration directory %CATALINA_HOME%\conf\Catalina\www.domain.at.
- The IP address of the desired hostname “www.domain.at” MUST resolve to the IP of the Tomcat server!
Creating a Tomcat Virtual Host
The desired VirtualHost has to be added to the Server.xml in the CATALINA_HOME directory:
<Host name="www.domain.at" appBase="D:/Websites/www.domain.at/webapps" unpackWARs="false" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="D:/Websites/www.domain.at/logs" prefix="tomcat_log."
suffix=".txt" pattern="%h %l %u %t %r %s %b" />
</Host>
Then restart the Tomcat service.
Setting Up the Webapp
- Put the finished application in the ROOT directory below the application directory.
- The application must contain a valid “web.xml” configuration file in the “WEB-INF” subdirectory.
Example Web Application
webapps
+---test
+---calendar
¦ +---img
+---images
+---WEB-INF
+---classes
+---com
¦ +---[...]
+---dbtools
+---test
Integration into Apache Httpd
Create a new worker for the virtual host in worker.properties:
worker.list=workerDOMAIN
worker.workerDOMAIN.type=ajp13
worker.workerDOMAIN.host=www.domain.at
worker.workerDOMAIN.port=8009
In the
JkMount /* workerDOMAIN
Note: “JkMount /test/* workerDOMAIN” maps the request www.domain.at/test/ to the directory www.domain.at:8009/test/ on Tomcat!