Wednesday, 10 December 2008

Install Apache Tomcat in Ubuntu (VirtualBox)

Start your Ubuntu virtualBox server and using firefox download the latest tomcat image from http://tomcat.apache.org and install it as follows:

Install and Configure Tomcat



  • open firefox and navigate to tomcat.apache.org

  • From the Download menu, select Tomcat 6.x

  • From Binary Distributions (Core) select the tar.gz image

  • This will download the file apache-tomcat-6.0.18.tar.gz onto your Desktop

  • Open a Terminal window (Applications->Accessories->Terminal) and perform the following:

    cd Desktop
    sudo mv apache-tomcat-6.0.18.tar.gz /opt
    cd /opt
    sudo gunzip apache-tomcat-6.0.1.18.tar
    sudo tar xvf apache-tomcat-6.0.18.tar
    sudo rm -f apache-tomcat-6.0.18.tar


  • Create a tomcat user and change the owner of all the extracted files to tomcat as follows:

    sudo useradd -g 46 -s /sbin/nologin -d /opt/tomcat/temp tomcat
    sudo chown -R tomcat apache-tomcat-6.0.1.18


  • Edit the /etc/profile to set the CATALINA_HOME environment variable as follows:

    sudo vi /etc/profile
    add export CATALINA_HOME=/opt/apache-tomcat-6.0.18


  • create/edit the setenv.sh tomcat file as follows:

    vi /opt/apache-tomcat-6.0.18/bin/setenv.sh


  • add the following lines to the setenv.sh file

    export CATALINA_HOME=/opt/apache-tomcat-6.0.18
    export JAVA_HOME=/usr/jdk1.6.0_10


  • reboot your server


Create scripts to start and stop the Server


Create a bin sub-directory in your home directory and add the scripts startServer and stopServer as follows:

cd
mkdir bin
cd bin

create the startServer script as follows:

vi startServer

add the following line to startServer

sudo -u tomcat /opt/apache-tomcat-6.0.18/bin/startup.sh

Now create the stopServer script as follows:

vi stopServer

add the following line to stopServer

sudo -u tomcat /opt/apache-tomcat-6.0.18/bin/shutdown.sh

Now set the scripts to executables as follows:

chmod 755 startServer stopServer

Start and Verify that the Tomcat Server is running


In your terminal session enter the following:

startServer

Open firefox and navigate to the following url

http://localhost:8080

No comments:

Post a Comment