Installing mod_jk in 1 Minute!

Apache mod_jk Installation Quick Guide

mod_jk is AJP connector connecting Apache with tomcat. It enables users access tomcat/JSP thru Apache.

Key Components
1. httpd.conf LoadModule
2. workers.properties
3. modules/mod_jk.so



Two ways of installing modules in apache, Static or DSO (Dynamic Shared Object):

Static - compiled with apache ./configure --with-mod_jk
DSO - must have mod_so compiled with apache, use apxs (apache extensons) to add.


"httpd -l" to see static modules compiled with apache, mod_so.c must be on the list to use DSO.

"httpd -M" to see list of all modules both static and dynamic


-bash-3.00$ /usr/local/apache2/bin/httpd -M
Loaded Modules:
core_module (static)
authn_file_module (static)
authn_default_module (static)
authz_host_module (static)
authz_groupfile_module (static)
authz_user_module (static)
authz_default_module (static)
auth_basic_module (static)
auth_digest_module (static)
include_module (static)
filter_module (static)
deflate_module (static)
log_config_module (static)
env_module (static)
headers_module (static)
setenvif_module (static)
version_module (static)
ssl_module (static)
mpm_prefork_module (static)
http_module (static)
mime_module (static)
status_module (static)
autoindex_module (static)
asis_module (static)
cgi_module (static)
negotiation_module (static)
dir_module (static)
actions_module (static)
userdir_module (static)
alias_module (static)
rewrite_module (static)
so_module (static)
jk_module (shared)


To install via DSO:

Building mod_ jk on Linux/*nix

You need to make sure you have the required gcc compiler and libc versions on your Linux system to
compile the Apache Web server and mod_jk . The specific version required is dependent on the Apache
Web server that you will be using. In addition, the script used by mod_jk installation requires installation
of libtool 1.5.2 or higher, and at least autoconf 2.59 .

1. Download the source of the Apache Web server, corresponding to the version of the server you
are using, from http://httpd.apache.org/download.cgi .

2. Unpack the distribution into any convenient directory, such as /home/dev/httpd-2.2.3 .

3. Download the latest Connector source from http://tomcat.apache.org/downloadconnectors.cgi

4. Unpack it to a convenient directory, such as /home/dev/tomcat-connects-1.2.19-src .

5. Compile and install the Apache server. You should follow the detailed instructions in the install
file of your Apache server source directory. With the 2.2.3 server, you need to issue the command
./configure --prefix=/installdir where you can specify the location ( installdir ) where
you want the server to be installed. After configuration finishes, type the make command to compile
the source. Finally, type the make install command to install the server.


6. This step compiles the mod_jk module as a dynamically loadable module. Change into the
native subdirectory. Then enter the command ./configure --with-apxs=/installdir/bin/apxs .
The installdir must be the same as the installation directory of your Web server in step 5;
be aware that this is not the same as the source code directory for the Web server. This creates
a makefile. You can then type make to compile the mod_jk module. You can then find the
mod_jk.so module in the apache-2.0 subdirectory.



Basic Terms:

Servlets

A servlet is a Java class that runs in a Java-enabled server. An HTTP servlet is a special type of servlet that handles an HTTP request and provides an HTTP response, usually in the form of an HTML page. The most common use of WebLogic HTTP Servlets is to create interactive applications using standard Web browsers for the client-side presentation while WebLogic Server handles the business logic as a server-side process. WebLogic HTTP servlets can access databases, Enterprise JavaBeans, messaging APIs, HTTP sessions, and other facilities of WebLogic Server.

Servlets and Java EE

WebLogic Server fully supports HTTP servlets as defined in the Servlet 2.5 specification from Sun Microsystems.

The Servlet 2.5 specification defines the implementation of the servlet API and the method by which servlets are deployed in enterprise applications. Deploying servlets on a Java EE-compliant server, such as WebLogic Server, is accomplished by packaging the servlets and other resources that make up an enterprise application into a single unit, the Web application. A Web application utilizes a specific directory structure to contain its resources and a deployment descriptor that defines how these resources interact and how the application is accessed by a client. See The Web Applications Container.


What You Can Do with Servlets

* Create dynamic Web pages that use HTML forms to get end-user input and provide HTML pages that respond to that input. Examples of this utilization include online shopping carts, financial services, and personalized content.

* Create collaborative systems such as online conferencing.

* Easily deploy servlets written for any Java EE-compliant servlet engine to WebLogic Server.

* Have access to a variety of APIs and features by using servlets running in WebLogic Server. For example:
1) Session tracking—Allows a Web site to track a user’s progress across multiple Web pages. This functionality supports Web sites such as e-commerce sites that use shopping carts. WebLogic Server supports session persistence to a database, providing fail-over between server down time and session sharing between clustered servers. For more information see Session Tracking from a Servlet.
2) JDBC drivers (including Oracle)—JDBC drivers provide basic database access. With WebLogic Server’s multi-tier JDBC implementations, you can take advantage of connection pools, server-side data caching, and transactions. For more information see Accessing Databases.
3) Enterprise JavaBeans—Servlets can use Enterprise JavaBeans (EJB) to encapsulate sessions, data from databases, and other functionality. See Referencing External EJBs, More about the ejb-ref* Elements, and Referencing Application-Scoped EJBs.
4) Java Messaging Service (JMS)—JMS allows your servlets to exchange messages with other servlets and Java programs. See Programming WebLogic JMS.
5) Java JDK APIs—Servlets can use the standard Java JDK APIs.
6) Forwarding requests—Servlets can forward a request to another servlet or other resource. Forwarding a Request.




WAR files
Web Application Development Key Points

JSPs and HTTP servlets can access all services and APIs available in WebLogic Server. These services include EJBs, database connections by way of
Java Database Connectivity (JDBC), Java Messaging Service (JMS), XML, and more.

A Web archive (WAR file) contains:

* One servlet or Java Server Page (JSP), along with any helper classes.
* A weblogic.xml deployment descriptor, which is an XML document containing WebLogic Server-specific elements for Web applications.
* An optional web.xml deployment descriptor, which is a Java EE standard XML document that describes the contents of a WAR file.
* A WAR file can also include HTML or XML pages and supporting files such as image and multimedia files.

The WAR file can be deployed alone or packaged in an Enterprise application archive (EAR file) with other application components. If deployed alone, the
archive must end with a .war extension. If deployed in an EAR file, the archive must end with an .ear extension.

Oracle recommends that you package and deploy your stand-alone Web applications as part of an Enterprise application. This is an Oracle best practice,
which allows for easier application migration, additions, and changes. Also, packaging your applications as part of an Enterprise application allows
you to take advantage of the split development directory structure, which provides a number of benefits over the traditional single directory structure.