-Add Canonical partners repository to apt sources (uncomment the lines)
vi /etc/apt/sources.list
deb http://archive.canonical.com/ubuntu lucid partner deb-src http://archive.canonical.com/ubuntu lucid partner
/etc/apt/sources.list.d/canonical.com.list ?
apt-get install sun-java6-jre
OPTIONAL IF YOU'VE ALREADY INSTALLED OPENJDK update-java-alternatives --jre-headless -s java-6-sun
-Install libtcnative-1 and tomcat6 apt-get install libtcnative-1 tomcat6
-Add logrotate configuration /etc/logrotate.d/tomcat6
-Replace Tomcat defaults file /etc/default/tomcat6
Modify the Config files /etc/tomcat6/server.xml
Obviously you need the certificate in place too
/var/lib/ssl
cert.crt cert.key
(If getting error that cannot check up the chain / contact vendor )
YOU MIGHT NEED AN INTERMEDIATE CERTIFICATE /var/lib/ssl/intermediate.crt (e.g. .pem must be downloaded from your CA SSL provider)
ALTERNATE METHOD http://tomcat.apache.org/tomcat-6.0-doc/ssl-howto.html
sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner" sudo apt-get update sudo apt-get install unzip sudo apt-get remove openjdk-6-jre-headless apt-get install sun-java6-jdk sun-java6-plugin sun-java6-fonts update-java-alternatives -s java-6-sun
AUTHBIND
sudo nano /etc/default/tomcat6
... end of file
(yes/no, default: no)
AUTHBIND=yes
verify by seeing /etc/passwd's tomcat user ID number (e.g. 108) sudo ls /etc/authbind/byuid/
EXTRA - NOT NECESSARY AS UBUNTU tomcat6 meta package does it already apt-get install authbind touch /etc/authbind/byport/443 chown tomcat6:tomcat6 /etc/authbind/byport/443
SUN (ORACLE?) JAVA
alternatives --display java alternatives --config java yum remove java (this will attempt to remove openjdk if it was already installed) yum remove tomcat yum remove tomcat5
http://www.oracle.com/technetwork/java/javase/downloads/
Download the appropriate JDK...
wget http://download.oracle.com/otn-pub/java/jdk/6u25-b06/jdk-6u25-linux-x64-rpm.bin
mv jdk-6u25-linux-x64-rpm.bin\?e\=1306979603\&h\=d2825a89b9b485a73261d181c7ffc95e jdk-6u25-linux-x64-rpm.bin chmod +x jdk-6u25-linux-x64-rpm.bin
./jdk-6u25-linux-x64-rpm.bin
java -version
java version "1.6.0_25"
Java(TM) SE Runtime Environment (build 1.6.0_25-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.0-b11, mixed mode)
rhel-centos-yum-install-tomcat6-enable-rpmforge
cd /etc/yum.repos.d
(prepare for Tomcat6 installation) wget http://www.jpackage.org/jpackage50.repo
YOU MIGHT WANT TO ENABLE RPMforge... http://rpmrepo.org/RPMforge/Using
$dist = el5 $arch = x86_64
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm
rpm -Uhv rpmforge-release-0.5.2-2.$dist.rf.$arch.rpm
warning: rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 6b8d79e6
Preparing... ########################################### [100%]
1:rpmforge-release ########################################### [100%]
mv /etc/yum.repos.d/rhel* /home/USERNAME/Archive
yum install tomcat6
(1/9): jakarta-commons-collections-tomcat5-3.1-9.jpp5.noarch.rpm | 28 kB 00:00
(2/9): tomcat6-el-1.0-api-6.0.29-1.jpp5.noarch.rpm | 37 kB 00:00
(3/9): jakarta-commons-pool-tomcat5-1.3-11.jpp5.noarch.rpm | 47 kB 00:00
(4/9): tomcat6-jsp-2.1-api-6.0.29-1.jpp5.noarch.rpm | 74 kB 00:00
(5/9): tomcat6-6.0.29-1.jpp5.noarch.rpm | 83 kB 00:00
(6/9): tomcat6-servlet-2.5-api-6.0.29-1.jpp5.noarch.rpm | 88 kB 00:00
(7/9): jakarta-commons-dbcp-tomcat5-1.2.2-2.jpp5.noarch.rpm | 112 kB 00:00
(8/9): ecj-3.3.1.1-3.jpp5.noarch.rpm | 1.3 MB 00:00
(9/9): tomcat6-lib-6.0.29-1.jpp5.noarch.rpm | 2.8 MB 00:01
INTERESTING DISTRIBUTION NOTE
Centos 5.x with tomcat6 installs /usr/share/tomcat6 with symlinks to the relevant locations Also, cat /etc/passwd reveals that the user is tomcat, whereas in Ubuntu it's tomcat6
NOTE: MODIFY tomcat to use port 80 instead of the default 8080 for improved Firewall accessible testing...
vi /etc/tomcat6/server.xml
upload and move HelloServlet.war into /var/lib/tomcat6/webapps chown tomcat:tomcat /var/lib/tomcat6/webapps/HelloServlet.war
service tomcat6 start
VERIFYING THE TOMCAT6 LOGS... vi /var/log/tomcat6/catalina.out
SEVERE: Error initializing endpoint
java.net.BindException: Permission denied
ANSWER: we need authbind installed and configured for tomcat6
(http://en.wikipedia.org/wiki/Authbind)
wget http://www.chiark.greenend.org.uk/ucgi/~ijackson/cvsweb/authbind/authbind.tar.gz?tarball=1 -O authbind.tar
tar -xf authbind.tar
cd authbind
make
cc -g -O2 -Wall -Wwrite-strings -Wpointer-arith -Wimplicit -Wnested-externs -Wmissing-prototypes -Wstrict-prototypes -DMAJOR_VER='"1"' -DMINOR_VER='"0"' -DLIBAUTHBIND='"/usr/local/lib/authbind/libauthbind.so.1"' -DHELPER='"/usr/local/lib/authbind/helper"' -DCONFIGDIR='"/etc/authbind"' -D_GNU_SOURCE -c -o authbind.o authbind.c cc -g authbind.o -o authbind cc -g -O2 -Wall -Wwrite-strings -Wpointer-arith -Wimplicit -Wnested-externs -Wmissing-prototypes -Wstrict-prototypes -DMAJOR_VER='"1"' -DMINOR_VER='"0"' -DLIBAUTHBIND='"/usr/local/lib/authbind/libauthbind.so.1"' -DHELPER='"/usr/local/lib/authbind/helper"' -DCONFIGDIR='"/etc/authbind"' -D_GNU_SOURCE -c -o helper.o helper.c cc -g helper.o -o helper cc -D_REENTRANT -g -O2 -Wall -Wwrite-strings -Wpointer-arith -Wimplicit -Wnested-externs -Wmissing-prototypes -Wstrict-prototypes -DMAJOR_VER='"1"' -DMINOR_VER='"0"' -DLIBAUTHBIND='"/usr/local/lib/authbind/libauthbind.so.1"' -DHELPER='"/usr/local/lib/authbind/helper"' -DCONFIGDIR='"/etc/authbind"' -D_GNU_SOURCE -c -o libauthbind.o -fPIC libauthbind.c ld -shared -soname libauthbind.so.1 -o libauthbind.so.1.0 libauthbind.o -ldl -lc
make install install -o root -g root -m 755 -d /usr/local/lib/authbind /usr/local/share/man/man1 /usr/local/share/man/man8 install -o root -g root -m 755 -s authbind /usr/local/bin/. install -o root -g root -m 644 libauthbind.so.1.0 /usr/local/lib/authbind/. strip --strip-unneeded /usr/local/lib/authbind/libauthbind.so.1.0 ln -sf libauthbind.so.1.0 /usr/local/lib/authbind/libauthbind.so.1 install -o root -g root -m 755 -s helper /usr/local/lib/authbind/. chmod u+s /usr/local/lib/authbind/helper install -o root -g root -m 755 -d /etc/authbind \ /etc/authbind/byport /etc/authbind/byaddr /etc/authbind/byuid
CONFIGURE AUTHBIND WITH TOMCAT ON PORT 80
touch /etc/authbind/byport/80 chmod 500 /etc/authbind/byport/80 chown tomcat:tomcat /etc/authbind/byport/80
(REPEAT IF NECESSARY FOR PORT 443)
vi /etc/init.d/tomcat6
TOMCAT_SCRIPT="/usr/sbin/tomcat6" becomes TOMCAT_SCRIPT="exec authbind --deep /usr/sbin/tomcat6"
vi /etc/tomcat6/tomcat6.conf CATALINA_OPTS="-Djava.net.preferIPv4Stack=true"
service tomcat6 start netstat -an (SHOULD SHOW YOU LISTENING on port 80)
YOU WILL SEE THIS ERROR IF SOMEHOW YOUR TOMCAT IS RUNNING IPV6 (AUTHBIND ONLY WORKS ON IPV4) tomcat java.lang.Exception: Socket bind failed: [13] Permission denied
APPARENTLY LIBAPR BELOW SOMEHOW FORCES IPV6?!?!?!
set JAVA_OPTS="-Djava.net.preferIPv4Stack=true"
SO FAR AS I CAN TELL, CENTOS 5 (RHEL 5) LIBAPR AND AUTHBIND ARE MUTUALLY EXCLUSIVE DUE TO AUTHBIND BEING INCOMPATIBLE WITH IPV6 AND LIBAPR SEEMING TO OVERRIDE THE JAVA_OPTS AND RUNNING IN IPV6
service tomcat6 start netstat -an (SHOULD SHOW YOU LISTENING on port 80)
vi /var/log/tomcat6/catalina.out
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path
yum install apr-devel openssl-devel
http://tomcat.apache.org/native-doc/ wget http://www.apache.org/dist/tomcat/tomcat-connectors/native/1.1.20/source/tomcat-native-1.1.20-src.tar.gz tar -xzvf tomcat-native-1.1.20-src.tar.gz
cd tomcat-native-1.1.20-src/jni/native
" ./configure --with-apr=$HOME/APR --with-java-home=$JAVA_HOME --with-ssl=$HOME/OPENSSL --prefix=$CATALINA_HOME" $CATALINA_HOME is the path where the produced libraries will be installed.
./configure --with-apr=/usr/bin/apr-1-config
"checking for JDK location (please wait)... checking Try to guess JDK location... configure: error: can't locate a valid JDK location"
./configure --with-apr=/usr/bin/apr-1-config --with-java-home=/usr/java/jdk1.6.0_25 make make install
"Libraries have been installed in: /usr/local/apr/lib"
NOW TO INFORM TOMCAT OF THE NEW LIBRARY LOCATION:
vi /etc/tomcat6/tomcat6.conf JAVA_OPTS="-Djava.library.path=/usr/local/apr/lib"
OR ln -s /usr/local/apr/lib/libtcnative-1.so.0.1.20 /usr/lib/libtcnative-1.so
ln -s /usr/local/apr/lib/libtcnative-1.so.0.1.20 /usr/lib64/libtcnative-1.so
http://ipaddressordns/projectname/classname
Sample Java Source Code for Eclipse dynamic Web Project Hello Servlet with class Hello
import java.io.PrintWriter; import java.io.IOException;
import javax.servlet.; import javax.servlet.http.;
// Extending the servlet class for custom behavior public class Hello extends HttpServlet { //Eclipse warning prompted an Eclipse fix private static final long serialVersionUID = 1L;
// overriding the HHTP "Get" request so that this page will do something...
public void doGet( HttpServletRequest request , HttpServletResponse response )
throws ServletException , IOException
{
PrintWriter out = response.getWriter();
out.println( "Hello" );
}
}// end class Hello