This article contains step by step instructions for configuring an Apache 2.x web server which handles static content and delegates JSP (Java Server Pages) and Servlet requests to two Tomcat 4.x servers using AJP 13 connectors and a load balancing worker.

Introduction

Apache 2.0 is a standards compliant, fast and mature web server which excels at delivering static content such as static HTML pages and images. The Tomcat web server is great for serving Java Server Pages and servlets, but it is not as fast as Apache for delivering static content.

In order to build a fast, scalable web application, the requirements call for an Apache server that delegates servicing of JSP and servlet requests to multiple tomcat servers by using an Apache module, mod_jk, that performs load balancing with session affinity, also known as “sticky” sessions.

Session affinity explained. When a client browser requests a JSP page for the first time, the load balancer redirects the request received by Apache to one of the two tomcat servers; further requests originating from the same client session will be automatically forwarded to the same tomcat server, so that the user’s session data is retrieved.

This document describes how I configured Apache 2.x to dispatch JSP and servlet requests to two Tomcat 4.x instances listening on different ports. This setup was done on a Linux system. Your mileage may vary.

Read more

Post to Twitter Post to Yahoo Buzz Post to Delicious Post to Digg Post to Reddit Post to StumbleUpon

Share or Bookmark This Post With :

This FlashGuideTM covers integrating Apache 1.3.x and Tomcat 4.x on Unix via mod_jk. These instructions have been tested on SuSE 9.0, Red Hat 6.2 and Fedora Core 2. There are two ways to integrate Apache and Tomcat: mod_jk and mod_jk2. Mod_jk is the older but more stable version, which supports load balancing and non-standard web application locations. Mod_jk2 is newer, has bugs, and, as of 11/15/04, is no longer being actively developed.

These instructions are for the current version of Tomcat 4.1.31, but have worked the same for all previous versions of Tomcat.

If you are using an older version of Tomcat, note that there are known bugs when using mod_jk and Tomcat 4.0.1 or 4.0.2, so you must use 4.0.3 or greater.

1. Building Apache 1.3.x on Linux

Unless you can find a binary distribution of Apache with DSO support enabled, you will have to follow these instructions to build it yourself.

1. Check your prerequisites:

1. You will need GCC installed
2. You will need /usr/ccs/bin and the gcc executables in your $PATH

2. Download the latest Apache source from http://httpd.apache.org/download.cgi – currently, the latest is 1.3.33.
3. Unpack the distribution into a development directory (I used /usr/local)

The distribution directory will be something like apache_1.3.33
4. Cd into the distribution directory (e.g. /usr/local/apache_1.3.33)
5. Configure the makefile:

./configure –with-layout=Apache –prefix=/usr/local/apache –enable-rule=SHARED_CORE –enable-module=so

Read More

Post to Twitter Post to Yahoo Buzz Post to Delicious Post to Digg Post to Reddit Post to StumbleUpon

Share or Bookmark This Post With :

In this tutorial, apache2 server is installed through wamp server for PHP under c:/wamp/Apache2.

Download and install

Configuration

  • Java JDK path : C:\jdk1.5.0_07
  • Apache path : C:\wamp\Apache2
  • Tomcat path : C:\tomcat5
  • JSP/Servlet webroot (via Apache2/mod_jk) : C:\tomcat5\webapps
  • JSP/Servlet webroot (via native Tomcat server, port 8080) : C:\tomcat5\webapps
  • Access JSP/Servlet pages via Apache2/mod_jk : http://localhost/[jkmount-mapped url of your webapp]
  • Access native Tomcat server : http://localhost:8080/

Unpack and place Tomcat5 and mod_jk

  • Unpack file apache-tomcat-5.5.17.tar.gz under directory C:\
  • Rename directory C:\apache-tomcat-5.5.17 to C:\tomcat5
  • Rename file mod_jk-apache-2.x.xx.so to mod_jk.so, and place under directory C:\wamp\Apache2\modules. In wamp its already compiled and installed under c:/wamp/Apache2/modules

Configuration and Setup

workers.tomcat_home=C:/tomcat5
workers.java_home=C:/jdk1.5.0_07
ps=\
# Define worker 'example'
worker.list=example,worker1,worker2,worker3
# Set properties for worker 'example' (ajp13)
worker.example.type=ajp13
worker.example.host=localhost
worker.example.port=8009
worker.example.cachesize=10
worker.example.cache_timeout=600
worker.example.socket_keepalive=1
worker.example.recycle_timeout=300

# Set properties for worker1
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8109
# Set properties for worker2
worker.worker2.type=ajp13
worker.worker2.host=localhost
worker.worker2.port=8209
# Set properties for worker3
worker.worker3.type=ajp13
worker.worker3.host=localhost
worker.worker3.port=8309

Edit file C:\wamp\Apache2\conf\httpd.conf, insert code

LoadModule jk_module modules/mod_jk.so
<IfModule mod_jk.c>

JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogLevel error
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat "%w %V %T"

Alias /jsp-examples "C:/tomcat5/webapps/jsp-examples/"
<directory>
Options Indexes +FollowSymLinks
AllowOverride None
Allow from all
</directory>

Alias /servlets-examples "C:/tomcat5/webapps/servlets-examples/"
<directory>
Options Indexes +FollowSymLinks
AllowOverride None
Allow from all
</directory>

<location /*/WEB-INF/*>
AllowOverride None
deny from all
</location>

JkMount /jsp-examples/*.jsp example
JkMount /servlets-examples/* example
</IfModule>

If you dont want to mount some files or directories, you can exclude using JkUnMount

Install and Start Tomcat

Tomcat can be installed as a Service or started as a Standalone Console application. Note to make sure that Apache has been started at this point.

Post to Twitter Post to Yahoo Buzz Post to Delicious Post to Digg Post to Reddit Post to StumbleUpon

Share or Bookmark This Post With :

   
Subscribe to RSS Feeds Follow me on Twitter Add to Favourite
 
Sponsors
 
Tags
 
Network [+]
 
© Copyright 2009 - 2011 TechiePark.com. All Rights Reserved | Powered by WordPress
This work is licensed under a Creative Commons Attribution 3.0 Unported License
Php5 powered    Mysql powered    Apache powered   Best viewed with  Spread Firefox Affiliate Button