How to install Tomcat and Apache on Ubuntu
Learn how to install Apache and Tomcat on a Linux server running Ubuntu, just in case you aren't already using the world's best Java host:
Note: # prompt is root and $ prompt is the user prompt
1- Upload JDK bin - preferably Oracle Sun JDK.
(be sure to get 32 or 64 based on what you using for your OS)
# cd /usr/
# mkdir java
# cd java
# wget build.javapipe.net/files/jdk/jdk1.6.0_33-32bit.zip
# unzip jdk1.6.0_33-32bit.zip
Note: If unzip does not work then do apt-get install unzip and try again.
2- Create symlink to simplify so that you can create path to it as /usr/java/jdk6
# ln -s jdk1.6.0_33 jdk6
3- Create user and home directory to host your tomcat and set shell to bash
# useradd -d /home/myapp -m myapp
# chsh myapp -s /bin/bash
4- Change to user and set JAVA_HOME
# su - myapp
$ nano .bashrc
Add the following at the end of the file:
## JAVA_HOME variables JAVA_HOME=/usr/java/jdk6 PATH=$JAVA_HOME/bin:$PATH export JAVA_HOME
5- Save file then run following command to initialize.
$ . .bashrc
$ java -version
You should get this output if it works:
java version "1.6.0_33"
Java(TM) SE Runtime Environment (build 1.6.0_33-b04)
Java HotSpot(TM) Client VM (build 20.8-b03, mixed mode)
7- Get apache tomcat
$ wget http://mirror.sdunix.com/apache/tomcat/tomcat-7/ \\ v7.0.29/bin/apache-tomcat-7.0.29.tar.gz
8- Untar and create symlink
$ tar xvzf apache-tomcat-7.0.29.tar.gz
$ ln -s apache-tomcat-7.0.29 tomcat
$ rm apache-tomcat-7.0.29.tar.gz
9- Start up your tomcat container to see if it works
$ cd tomcat/bin
10- Test your installation
Test by opening your browser and going to http://YOURIP:8080 and you should be greeted with the Tomcat welcome page.
Package your application into a WAR file and upload to your /home/myapps/tomcat/webapps/