Running servlets under Linux
Much of the following information is taken from http://jakarta.apache.org/tomcat/tomcat-4.1-doc/RUNNING.txt
- Make sure your Apache server is running. (One easy way is to do a ps
-augx | grep httpd, you should see a number of entries.) If it isn't,
you can manually start Apache via apachectl start, but you'll have
to be superuse to do so.
- Obtain Jakarta Tomcat, a servlet container for
web servers (including Apache). Jakarta.apache.org
- Current Tomcat release is 4.1.18, which supports JSP v1.2 and Servlet
v2.3.
- Full documentation at http://jakarta.apache.org/tomcat/tomcat-4.1-doc/index.html
- You must obtain a recent JDK (v1.2 or better). http://java.sun.com/j2se
- Download a binary distribution of Tomcat from: http://mirrors.midco.net/pub/apache.org/jakarta/tomcat-4/binaries/
(for a linux installation, you’ll want to download
jakarta-tomcat-4.0-YYYYMMDD.tar.gz (where the “YYYYMMDD” corresponds to the
date when the release was put there.)) If you want to save a step, download
this file into /usr/local/
Installing J2SE (JDK)
(Also, see http://www.halley.cc/ed/linux/howto/java.html.)
- Download JDK from javasoft.com. You should obtain the RPM version for linux.
- The result will be a file j2sdk-1_4_1_01-linux-i586-rpm.bin
- chmod j2sdk-1_4_1_01-linux-i586-rpm.bin,
to make that file executable.
- Switch to super-user mode.
- Move the file to be in /usr/local. cd
to that directory
- Do ./j2sdk-1_4_1_01-linux-i586-rpm.bin, to run the
program.
- You will be asked a licensing question. If you answer yes, java will be
unpacked, yielding the file, j2sdk-1_4_1_01-fcs-linux-i586.rpm.
- To complete the installation install the rpm’s: rpm –ivh
j2sdk-1_4_1_01-fcs-linux-i586.rpm
- You’ll need to update your PATH environment variable to contain the location
of the java executables (like java and javac).
You should create the file /etc/profile.d/java.sh and /etc/profile.d/java.csh.
Then do source /etc/profile, and check the value of your PATH variable
by doing echo $PATH.
Starting Tomcat:
- Move the downloaded Tomcat distribution, jakarta-tomcat-4.0-YYYYMMDD.tar.gz,
to /usr/local/.
- cd /usr/local
- gunzip jakarta-tomcat-4.0-YYYYMMDD.tar.gz
- tar xf jakarta-tomcat-4.0-YYYYMMDD.tar
- You should now see a Jakarta-tomcat directory in /usr/local,
it's probably called jakarta-tomcat-4.1.18. You can now delete the .gz and .tar files, if you want.
- To start tomcat: cd /usr/local/jakarta-tomcat-4.1.18/bin
- Do ./startup.sh
You can test the Tomcat is running by having your browser open http://localhost:8080/.
You should see a default Tomcat page. There is a link to JSP and Servlet examples
from that page. Try some of them.