Cis 5930 04 spring 2001
1 / 21

CIS 5930-04 – Spring 2001 - PowerPoint PPT Presentation

  • Uploaded on

Special Topic: Apache and Tomcat. CIS 5930-04 – Spring 2001. Instructors: Geoffrey Fox , Bryan Carpenter Computational Science and Information Technology Florida State University. The Apache Project.

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about ' CIS 5930-04 – Spring 2001' - tameka

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Cis 5930 04 spring 2001

Special Topic: Apache and Tomcat

CIS 5930-04 – Spring 2001

Instructors: Geoffrey Fox , Bryan Carpenter

Computational Science and Information Technology

Florida State University

[email protected]

The apache project
The Apache Project

  • The Apache Project is a collaborative software development effort.

  • Its goal is to produce a robust, commercial-grade, free HTTP server.

  • The project is run by volunteers—the Apache Group—communicating and planning through the Internet.

  • Organizational support is provided by the Apache Software Foundation.

  • Home page:

[email protected]

Foundation myths
Foundation Myths

  • Long ago, when the Web was young, the most famous Web server in the World was called the NCSA server.

  • It was developed by Rob McCool at the National Center for Supercomputing Applications.

  • McCool left NCSA in 1994, and development of the public-domain NCSA server temporarily faltered.

  • At that time, a group of eight powerful Webmasters had developed their own extensions and bug-fixes for the NCSA server.

  • The founding Webmasters—brought together by email—pooled their updates.

  • “Apache” came into being early in 1995. It was a series of “patches” to the NCSA code.

  • A year later, Apache was the most popular Web server.

[email protected]

Apache and tomcat
Apache and Tomcat

  • This “lecture” is mainly a how-to guide to installing the Apache server and integrating it with the current version of Tomcat.

  • This allows a site primarily served by Apache to seamlessly make servlet and JSP content available.

[email protected]

Obtaining apache for linux
Obtaining Apache for Linux

  • Go to and follow the“download”link.

  • Negotiate folders through to binaries/linux.

    • Or go directly to

  • At the time of writing, the relevant file was


[email protected]

Installing the apache server
Installing the Apache Server

  • Unpack the distribution:

    gunzip -c apache_1.3.14-i686-whatever-linux2.tar.gz | tar xvf -

    • You can do this step anywhere, e.g. in the /tmp directory.

  • Go into the created apache_1.3.4 directory and run


    • I will assume you are logged in asroot.

    • It should be straightforward to install as an ordinary user, but you need to ensure the Apache home directory is set to somewhere in your own home directory. Read the INSTALL.bindist file.

[email protected]

The installation script
The Installation Script

  • If successful, you will probably see a message something like:

    Installing binary distribution for platform i686-whatever-linux2

    into directory /usr/local/apache ...



    | You now have successfully installed the Apache 1.3.14 |

    | HTTP server. To verify that Apache actually works |

    | correctly you should first check the (initially |

    | created or preserved) configuration files: |

    | |

    | /usr/local/apache/conf/httpd.conf

    | |

    | You should then be able to immediately fire up |

    | Apache the first time by running: |

    | |

    | /usr/local/apache/bin/apachectl start

    | |

    | Thanks for using Apache. The Apache Group |

    | |


[email protected]

Customize the configuration file
Customize the Configuration File

  • If you wish, edit the file


  • The most likely changes you will need to make at this stage are to the document root.

  • For example I changed the lines:

    DocumentRoot “/usr/local/apache/htdocs”


    DocumentRoot “/home/httpd/html”


    <Directory “/usr/local/apache/htdocs”>


    <Directory “/home/httpd/html”>

  • If you are not installing as root, you will also need to change the line “Port 80” to specify a port above 1024.

[email protected]

Starting and stopping the server
Starting and Stopping the Server

  • As the installation script said, you can start the httpd server program by the command:

    /usr/local/apache/bin/apachectl start

  • Logically enough, you can stop it by:

    /usr/local/apache/bin/apachectl stop

[email protected]

Tomcat vs apache
Tomcat vs. Apache

  • The Apache Web server

    • is faster than Tomcat when it comes to static pages,

    • is more configurable than Tomcat,

    • is more robust than Tomcat, and

    • it supports CGI scripts, Server API modules, Perl, PHP, etc.

  • Hence for real world sites, Apache would generally be a better choice than Tomcat, except that. . .

    • In itself, Apache doesn’t support Servlets or JavaServer Pages!

[email protected]

Integrating apache and tomcat
Integrating Apache and Tomcat

  • The solution, of course, is to allow the two Web servers to work together.

  • The Apache server will be the principal server, dealing with static documents.

    • Or dynamic documents generated by any of the other technologies mentioned in the previous slide.

  • Apache will forward requests for Servlets or JavaServer Pages to Tomcat.

  • The approach we describe here is what was called the “out-of-process servlet container” the lectures on Servlets.

[email protected]

Out of process servlet container
Out-of-Process Servlet Container














[email protected]

The adapter
The Adapter

  • For Apache to communicate with Tomcat, and forward requests as necessary, it needs some extra software—an “adapter”.

  • An adapter will be implemented as an Apache module.

    • An Apache module is a piece of code that can be optionally linked in to (or left out of) the main server code.

    • Non-standard, plug-in, modules will typically be shared-object libraries (DLLs under Windows).

    • These live in a directory called /usr/local/apache/libexec.

  • Apache modules generally have names of the form mod_XXXX

    • For example, mod_perl.

  • There are two Tomcat adapter modules in common use: mod_jserv and mod_jk.

[email protected]

Mod jk

  • mod_jk is a new Tomcat-Apache plug-in that handles communication between Tomcat and Apache.

    • It replaces the older mod_jserv.

  • For more information, see the file doc/mod_jk-howto.html in the Tomcat release, which is also online at

  • For now the only way to obtain the mod_jk library for Linux seems to be to build it yourself. The sources are included in the source release of Tomcat.

[email protected]

Obtaining mod jk for linux
Obtaining mod_jk for Linux

  • Go to and follow the“Source Code”link.

  • Get the release build of Tomcat (currently 3.2).At the time of writing, the relevant file is


  • Unpack the distribution:

    gunzip -c jakarta-tomcat-3.2-src.tar.gz | tar xvf -

    • You can do this anywhere, e.g. in/tmp.

    • I do not particularly recommend you try to rebuild the Tomcat serveritself from this release: it is mucheasier just to download the compiled, “binary” version of the server, as described in the lectures on Servlets.

[email protected]

Building mod jk
Building mod_jk

  • Go to the directory


  • If necessary, edit the definition of the macro APXS in Makefile.linux so that it refers to the apxs command in the Apache release, probably /usr/local/apache/bin/apxs.

  • Build the library:

    make -f Makefile.linux

  • Install the plug-in in the Apache libexec/ directory, e.g.:

    cp /usr/local/apache/libexec

[email protected]

Updating the apache configuration
Updating the Apache Configuration

  • In the first instance (until you need to do something clever) this is very easy, because whenever the Tomcat server is run, it generates a self-describing “include” file.

    • This file contains a series of Apache configuration-file commands.

  • The include file is in


  • In my case I added the line

    include /home/users/dbc/jakarta-tomcat-3.2/conf/mod_jk.conf-auto

    to the end of the file /usr/local/apache/conf/httpd.conf.

[email protected]

Fragment of the file mod jk conf auto
Fragment of the File mod_jk.conf-auto


# Auto configuration for the /dbc context starts.


# The following line makes apache aware of the location of the /dbc context

Alias /dbc "/home/users/dbc/jakarta-tomcat-3.2/webapps/dbc"

<Directory "/home/users/dbc/jakarta-tomcat-3.2/webapps/dbc">

Options Indexes FollowSymLinks


# The following line mounts all JSP files and the /servlet/ uri to tomcat

JkMount /dbc/servlet/* ajp12

JkMount /dbc/*.jsp ajp12

# The following line prohibits users from directly accessing WEB-INF

<Location "/dbc/WEB-INF/">

AllowOverride None

deny from all


# The following line prohibits users from directly accessing META-INF

<Location "/dbc/META-INF/">

AllowOverride None

deny from all


[email protected]


  • Recall these are commands that Tomcat generates to configure Apache.

  • As the first comments indicates, these commands relate to the servlet context called dbc/.

  • The Alias command causes Apache to generally look in the Tomcat document directory for URLs with paths that start /dbc.

    • This is needed for static documents in the Tomcat directory.

  • The first JkMount command causes URLs with paths that match the pattern /dbc/servlet/* to be redirected to the AJP module (hence the Tomcat server).

  • The second JkMount command causes URLs with paths that match the pattern /dbc/*.jsp to be similarly redirected Tomcat server.

[email protected]

Configuring workers
Configuring “Workers”

  • In Tomcat 3.2, the generated include file, jakarta-tomcat-X.X/conf/mod_jk.conf-auto has a reference to the file in the same directory. You will probably have to manually edit this file.

  • Enclosed comments are fairly self-explanatory. If necessary change the Java home directory and the path-component separator (to / rather than \ for Linux).

  • You may also need to choose one or the other of ajp12 and ajp13, and comment out references to the other.

    • I went with ajp12. ajp13 is supposed to be an improved protocol, but I know and love ajp12.

  • Set the port number for your AJP connector, as specified in server.xml.

  • Seejakarta-tomcat-X.X/doc/Tomcat-Workers-HowTo.html.

[email protected]

Start the apache server
Start the Apache Server. . .

  • In principle, we are done. Restart the Apache server.

  • With the default configuration, URLs with paths in Tomcat servlet contexts that start /servlet or end with .jsp are redirected to Tomcat.

    • Note Apache will directly serve static .html pages, even if they are in the Tomcat document directory.

    • Because Apache (unlike Tomcat) runs as user nobody by default, such files now need to be world readable.

  • (Apparently) things continue to work across multiple restarts of Tomcat, even without restarting Apache.

    • We note however that, according to the FAQ, this is not the case with AJP13. . .

[email protected]