A GCJ-based servlet engine for Apache Mod_GCJ

Installing and configuring mod_gcj

mod_gcj can be used with both Apache 1.3 or 2.*. This document walks you through the basic steps of installing and configuring mod_gcj.


mod_gcj currently only runs only on Linux/Unix systems since it relies on Unix domain sockets and other features not available on Windows. You'll need the following in order to compile and install mod_gcj:

  • GCC including support for Java/GCJ. Version 4.1 is recommended. Earlier versions of GCC/GCJ may work to some degree, but have problems in classloading code that limit mod_gcj usability.

  • Apache HTTP Server version 1.3 or 2.*, including the development files (often packaged as apache-dev or apache-devel)

It is possible to run mod_gcj with a user-installed version of GCC/GCJ. Instructions for building and installing a GCJ snapshot can be found on the GCC web site.

Configuring and compiling mod_gcj

These are the steps to build and install mod_gcj.

        cd mod_gcj
        sudo make install

The configure script will try to find your GCC and Apache installations. In case it doesn't find them, or if you want to use other installations than those found (check the summary of settings the configure script prints out at the end) you can pass these values to ./configure with the following options:

Use this option to point the configure script to the APXS tool of the Apache installation you want to compile and install mod_gcj for.
Use this option to set the path to the main directory of the GCC installation to use. This is useful if your system uses an older version of GCC and you want to use a newer, user installed one.
This is only needed for Apache 2 installations where the Apache Portable Runtime (apr) header files are in a different directory than the Apache header files, and apr-config is in a different directory than apxs and can't be found automatically by the configure script.

Configuring Apache

After running make install, the module should have been copied to Apache's module directory, and mod-gcj-server should be in the Apache bin directory.

Open Apache's config file in a text editor and add the directives to load mod_gcj. For Apache 2.0 this is done using the LoadModule directive:

   LoadModule gcj_module   modules/mod_gcj.so

Note that the last part may change depending on the name of the module directory. Apache 1.3 requires the additional AddModule directive. Note that with Apache 1.3 the order of directives matters, because it determines module loading order.

   AddModule mod_gcj.c

Once this is done you can test if mod_gcj was installed successfully by adding the following lines to the config file and restarting Apache:

   <Location /test>
      SetHandler gcj
      GcjHandler org.helma.modgcj.test.TestHandler

If you now restart Apache and point your browser to http://localhost/test you should get a test page generated by mod_gcj.

mod_gcj Directives

mod_gcj adds the following configuration directives to Apache:

Defines the class name of servlet. This must be the name of a Java class that implements the javax.servlet.Servlet interface.
A list of directories/files/URLs in which to look for the handler class and its associated classes as a semicolon- or colon-separated list. Directories are automatically expanded to all contained .jar files.
The complete path to the mod-gcj-server binary. Defaults to the path mod-gcj-server was copied to by make install, which is file "mod-gcj-server" in the Apache binaries directory.
The path of the Unix domain socket file to use for communication between Apache/mod_gcj and mod-gcj-server. Defaults to /tmp/mod-gcj-server.

Building from CVS

If you are building a CVS snapshot, you'll need to bootstrap the configure script first.

      make -f Makefile.cvs

Note that you'll need recent versions of the GNU autotools (autoconf, automake, libtool) installed for this to work.