OK, here are the solution I found after searching lots of things:
http://www.oschina.net/question/12_21632
https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-on-ubuntu-12-04
My system is a Ubuntu 10.04 LTS (Lucid), the OPENJDK version is 1.6, and a Tomcat 6.
If you want to the install TOMCAT6, make sure you have Java installed first. Could check your Java installation by typing
Java-version
In your command line. If you see a error, you don't have java.
Regarding to the difference between OpenJDK and Sun Java, please refer to this blog:http://www.cnblogs.com/ruiyan/p/40986 30.html
Let ' s get started:
1. Install OpenJDK (Yes, you could definitely Install SUN-JAVA-JDK instead)
sudo Install openjdk-6-jdk
2. Check the installation of OpenJDK
Java-"1.6.0_33"1.13. 5) (6b33-1.13. 5-1ubuntu0. 10.04 23.25-b01, Mixed mode)
3. Set java_home Environmental variable (also configure. bashrc file)
After you install the OpenJDK, this directory would be created:/usr/lib/jvm/java-6-openjdk
So we set this directory as the Java_home environmental variable in ~:
sudo vim ~/.BASHRC
# can add the following in the end of BASHRC file
Export java_home=/usr/lib/jvm/java-6-openjdk
Export CATALINA_HOME=/USR/LOCAL/TOMCAT6
# Save and exit out of. bashrc file, make changes effective by restarting BASHRC file
. ~/.bashrc
4. Download and Install Tomcat6
sudo wget http://mirrors.gigenet.com/apache/tomcat/tomcat-6/v6.0.41/bin/ apache-tomcat-6.0.41.tar.gztar xvzf apache-tomcat-6.0. . Tar . GZ sudo MV apache-tomcat-6.0. /usr/local/tomcat6sudochmod755 /usr/local/tomcat6
5. Set automatic start for TOMCAT6 once the system starts
Create a file under/etc/init.d/using vim (Vim command cheat sheet:http://www.cnblogs.com/ruiyan/p/4093972.html)
sudo vim/etc/init.d/tomcat6
Edit the file with the following content:
# TOMCAT6 Server auto-Start Scriptexport java_home=/usr/lib/jvm/java-6-OpenJDK Case$1 inchstart)SH/usr/local/tomcat6/bin/startup.SH;; Stop)SH/usr/local/tomcat6/bin/shutdown.SH;; Restart)SH/usr/local/tomcat6/bin/shutdown.SHSH/usr/local/tomcat6/bin/startup.SH;;EsacExit0
6. Set executable Privilege
sudo chmod 755 /etc/init.d/tomcat6sudoln -s/etc/init.d/tomcat6/etc/rc1.d/k99tomcat sudoln -s/etc/init.d/tomcat6/etc/rc2.d/s99tomcat
7. Start Tomcat6
sudo sh /usr/local/tomcat6/bin/startup. SH
Using catalina_base: /usr/local/tomcatusing catalina_home: /usr/local/tomcatusing catalina_tmpdir:/usr/ Local/tomcat/tempusing jre_home: /usrusing CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar
8. Stop Tomcat6
sudo sh /usr/local/tomcat6/bin/shutdown. SH
After your finish all the above:
-Go to your server ip:8080 if is using a Ubuntu server to check Tomat
-Go to http://localhost:8080 if is using a local Ubuntu desktop/laptop.
If you see the good.
How does install OpenJDK and tomcat in Ubuntu server