Wednesday 5 June 2013

How to Change default port number in Tomcat on Ubuntu


Here i am going to show you how to change default port number in Tomcat.

Go to Tomcat folder

             manivel@manivel-admin:~$ cd /opt/tomcat/

You need to edit server.xml file. I am going to change default port 8089 to 8098

             manivel@manivel-admin:/opt/tomcat$ vim conf/server.xml 



You need to restart the Tomcat service after changing the port number.


manivel@manivel-admin:~$ sudo /etc/init.d/tomcat start

Now you can able to access Tomcat via port 8098. Go to browser and type localhost:8098


That solve...

Sunday 2 June 2013

How to Install and Configure Apache Tomcat on Ubuntu


Apache Tomcat is a web container that allows you to serve Java Servlets and JSP (Java Server Pages) web applications.Before you install Apache Tomcat you will want to make sure that you have installed Java (openjdk).

You can check with the dpkg command

               manivel@manivel-admin:~$ dpkg --list | grep openjdk

If that command has not given output, You need to install java

               manivel@manivel-admin:~$ sudo apt-get install openjdk


Apache Tomcat Installation

You will download and extract Tomcat.

               manivel@manivel-admin:/opt$ sudo wget http://www.poolsaboveground.com/apache/tomcat/tomcat-7/v7.0.40/bin/apache-tomcat-7.0.40.tar.gz

               manivel@manivel-admin:/opt$ sudo tar -zxf apache-tomcat-7.0.40.tar.gz

Create tomcat user and set home directory /opt/tomcat/

               manivel@manivel-admin:/opt$ sudo  useradd -d /opt/tomcat/ tomcat

Start the Tomcat service using following command

               manivel@manivel-admin:/opt/tomcat$ cd bin/

              manivel@manivel-admin:/opt/tomcat/bin$ ./startup.sh 
              Using CATALINA_BASE:   /opt/tomcat
              Using CATALINA_HOME:   /opt/tomcat
              Using CATALINA_TMPDIR: /opt/tomcat/temp
              Using JRE_HOME:        /usr
              Using CLASSPATH:       /opt/tomcat/bin/bootstrap.jar:/opt/tomcat/bin/tomcat-juli.jar
              manivel@manivel-admin:/opt/tomcat/bin$ 

Now The Tomcat will open default port 8089. Go to browser and type localhost:8089



Start up script for Tomcat


              manivel@manivel-admin:~$ sudo vim /etc/init.d/tomcat

    # Tomcat auto-start
    #
    # description: Auto-starts tomcat
    # processname: tomcat
    # pidfile: /var/run/tomcat.pid

    export JAVA_HOME=/usr/lib/jvm/java-6-openjdk

    case $1 in
    start)
            sh /opt/tomcat/bin/startup.sh
            ;;
    stop)  
            sh /opt/tomcat/bin/shutdown.sh
            ;;
    restart)
            sh /opt/tomcat/bin/shutdown.sh
            sh /opt/tomcat/bin/startup.sh
            ;;
    esac   
    exit 0

: wq


You will need to make the script executable by running the chmod command

             manivel@manivel-admin:~$ sudo chmod 755 /etc/init.d/tomcat

Now you can able to start the tomcat following command

            manivel@manivel-admin:~$ sudo /etc/init.d/tomcat start
            sudo: unable toresolve host manivel-admin
            Using CATALINA_BASE:   /opt/tomcat
            Using CATALINA_HOME:   /opt/tomcat
            Using CATALINA_TMPDIR: /opt/tomcat/temp
            Using JRE_HOME:        /usr/lib/jvm/java-6-openjdk
            Using CLASSPATH:       /opt/tomcat/bin/bootstrap.jar:/opt/tomcat/bin/tomcat-juli.jar
            manivel@manivel-admin:~$

I hope it will help you....