Linux Help

Apache Java Servlet Guide   
Printable Version

Kent's Apache Java Servlet Guide
Created on April 25th, 2000.

So this is my first guide and I really wanted it to be cool, but this should work for now =) Anyway, I'm gonna explain how to build, install and configure the Apache Java Servlet Engine to help out all you Java and web Developers. This is not an easy process and I do NOT recommend it for the beginning Apache neophytes, or people with heart conditions, this takes alot of time (took me 3 hours all together) and ALOT of patience. Now I stumbled upon this after purchasing Nikkei Linux Magazine, a Japanese Linux mag that really rocks, every month it comes with great articles (for those inclined to reading Japanese) and normally 2 CD's, one with some form of linux, including a couple distro's specific to Japan such as Laser5 Linux, Storm Linux and of course Nikkei Linux, but usually RedHat or TurboLinux are the most frequent distro. The second CD normally contains quite a few new neato programs, some beta, some old favorites but newer versions. I currently use my recent purchase of RedHat 6.1J, complete with a Japanese font server for X (I use Gnome for now, but will soon switch back to AfterStep) check out my screen shot on the users pages. Ok, 'nuf of my rambling, let's get to work....

Step 1:
First you need to get the packages we'll be using and save them to /usr/local/src.

To get the latest version of the Apache Java Servlet Engine 1.1 (jserv from here out) check out http://java.apache.org/jserv there are also very detailed documentation in the /docs dir. You'll need about 2 megs free space for ApacheJServ-1.1.tar.gz

And as long as you're close, hit up http://www.apache.org and snag yourself the most current version of Apache Web Server. You'll need about 2 megs free space for apache_1.3.12.tar.gz

And since the JavaSoft JSDK 2.0 (Java Servlet Developers Kit) is required visit http://java.sun.com/products/servlet/index.html (PLEASE NOTE: Version 2.0 and ONLY Version 2.0 will work with jserv) You'll need less than a meg free space. "jsdk20-solaris2-sparc.tar.Z" (oh, btw, according to Sun, even though this is the Solaris/Sparc source, it contains NO Solaris specific code, so it should run with all distro's of linux too, I didn't have any problems with it)

If you don't have one, you'll need a Java 1.1 compliant Runtime Environment, of course if you're a Java Coder, you should already have this, if not, visit http://java.sun.com/cgi-bin/java-ports.cgi and take your pick. You'll need 43 megs free space. "jdk1.2pre-v2.tar.bz2"

JDK 1.2 even comes with a Java Compiler (This is optional according to the README) so don't wreck yourself looking for one on the net.

Step 2:
Now we have all the files we need we need to untar/unzip them. Do this by running the following:

tar zxvf ApacheJServ-1.1.tar.gz

tar zxvf apache_1.3.11.tar.gz

tar zxvf jsdk20-solaris2-sparc.tar.Z

bunzip2 jdk1.2pre-v2.tar.bz2

tar xvf jdk1.2pre-v2.tar

That will put all the source and binaries into their own respective directories.

Step 3:
Now, let's setup our Java environments first.

While still in the /usr/local/src directory do:

mv JSDK2.0 /usr/local

Now add it to your search path:

set PATH /usr/local/JSDK2.0/bin:$PATH

To start the servlet server at boot time, add this to your /etc/rc.d/rc.local (if you run a Red Hat based system)

/usr/local/JSDK2.0/bin/servletrunner > /www.null 2> /www.null

(btw, much thanks to datoch for helping me finger that one out =)

If you wanna add more Java servlets or to setup the JSDK further check out the README on how to do this. For right now, I'm not really a Java guru and I'm more concerned with getting the jserv setup.

From here move the /usr/local/src/jdk1.2 directory to /usr/local:

mv /usr/local/src/jdk1.2 /usr/local/jdk

And add it to your path:

set PATH /usr/local/jdk/bin:$PATH

Step 4:
OK! Now we got all the hard stuff outta the way, let's get to the good stuff, setting up Apache and the compiling the jserv module:

Jump to the /usr/local/src/apache_1.3.12 directory and do:

./configure --prefix=/usr/local/apache

That gets Apache ready for the beating it's about to take. Now we add the jserv module:

cd ../ApacheJServ-1.1

(The following is word wrapped, the next 3 lines are all from one command)

./configure --prefix=/usr/local/jserv --with-apache-src=/usr/local/src/apache-1.3.11 
--with jdk-home=/usr/local/jdk --with-java=/usr/local/jdk/jre/bin 
--enable-compressed-jar  --enable-debugging --with-JSDK=/usr/local/JSDK2.0/lib

Is your Carpal Tunnel Syndrome acting up yet? Hehehe.

(just a quick breakdown of what all this does. --prefix= duh that tells it where to install the jserv binaries to, --with-apache-src= that tells it where to find your apache source files, --with-jdk-home= that tells it where to find the JDK, --with-java= that tells it where to find your Java compiler, --enable-compressed-jar compression is disabled by default, compression is always good! --enable-debugging, again, debugging is disabled by default, and all good www.lopers know, debugging is gooooood! And finally --with-JSDK= again, tells it where you installed the JSDK at, simple eh?)

Way off track, now let's compile and install/copy our jserv module for Apache:

make

make install

Step 5:
Alrighty then, moving back into the Apache source directory we do:

./configure --prefix=/usr/local/apache --activate-module=src/modules/jserv/libjserv.a

make

make install

Step 6:
Let's test to see if our mod_jserv has taken hold in Apache by executing:

/usr/local/apache/bin/httpd -l

It should spit something like this at you:

[root@dreamking ApacheJServ-1.1]# /usr/local/apache/bin/httpd -l
Compiled-in modules: 
  http_core.c
  mod_env.c
  mod_log_config.c
  mod_mime.c
  mod_negotiation.c 
  mod_php3.c
  mod_jserv.c 

If you see that...you're golden.

Step 7:
Some final configuration of the jserv is done in /usr/local/jserv/etc with the jserv.conf and jserv.properties files, poke around in them and make sure everything is pointing to where you want it to. Once you do that it comes with a leeto little example/test page for you to gaze at, point your web browser to:

http://www.yourserver.com/example/Hello

If you're happy with the way things are going, add Apache to your startup script and enjoy your Java in the morning and all day long.


Having trouble? Got questions? Require further assistance? If so please feel free to visit our Help Forums and ask the experts!


Copyright © 1997 - 2008 Private World Domination Inc. All rights reserved.
Linux is a registered trademark of Linus Torvalds. All other trademarks and copyrights are the property of their respective owners.
| Contact Us | Link to Us | RSS Feed | Staff |

DNS Hosting by easyDNS