Steps I took to get Java servlets to run under the Apache web server
Linux RedHat 5.2
Download the following distributions into /usr/local/src
gunzip and untar the .gz files from /usr/local/src
using: tar xvzf 'name'.gz
We need to set some environmental variables
Since I use bash logon shell, I set them in .bash_profile
Paths to set in .bash_profile
JAVA_HOME=/usr/local/src/jdk1.2
JSDK_HOME=/usr/local/src/JSDK2.0
For JDK < 1.2
CLASSPATH=$JAVA_HOME/lib/classes.zip:$JSDK_HOME/lib/jsdk.jar
For JDK = 1.2
CLASSPATH=$JSDK_HOME/lib/jsdk.jar
PATH=$JAVA_HOME/bin:$JSDK_HOME/bin:$PATH
Append path last because jar, java and javac also exist in /usr/bin!!
export PATH JAVA_HOME CLASSPATH
Logout then logon to have the paths set
Test the path settings:
# java -version
# servletrunner
If it looks ok then we can configure jserv.
# cd /usr/local/src/Apache-JServ-1.0b3
# ./configure --prefix=/usr/local/etc/jserv;make;make install
This should complete successfully if the paths are
properly set.
Created directories
/usr/local/etc/jserv
/usr/local/etc/jserv/doc
/usr/local/etc/jserv/lib
and the file /usr/local/etc/jserv/lib/Apache-JServ.jar
Now we need to compile Apache with servlet support.
- Copy the jserv modules to the Apache source extra modules directory
# cp /usr/local/src/Apache-JServ-1.0b3/src/c/*.* /usr/local/src/apache_1.3.4/src/modules/extra
- Compile Apache using the following options
# cd /usr/local/src/apache_1.3.4
# ./configure --prefix=/home/apache --add-module=src/modules/extra/mod_jserv.c --enable-shared=jserv --enable-module=jserv
# make;make install
Changes to configuration files
Append /usr/local/src/Apache-JServ-1.0b3/conf/http.conf.in to APACHE_DIR/conf/http.conf
Modify APACHE_DIR/conf/http.conf
- Modify ApJServProperties to point to the jserv.properties file
- Modify ApJServMount to point to a zone when requesting http://host/servlet/myServlet
ApJServMount /servlet /zone1
Modify jserv.properties file
- zones=zone1
- zone1.properties=PATH TO zone1.properties
- log.file = a place for the log file with a 777 mode (JDK1.2)
Modify zone1.properties
- repositories=PATH TO A SERVLET
- repositories=PATH TO ANOTHER SERVLET
Start apache /home/apache/bin/apachectl start
Include apache /home/apache/bin/apachectl start in /etc/rc.d/rc.local
Email
|