RSS

Tomcat 7.0 for Beginners

01 Oct

tomcat

tomcat


Tomcat, or officially named Apache Tomcat is a light-weight web container used for deploying and running web application based on Java. Just like apache for PHP as container, tomcat’s role is becoming a runtime for java web application. There are so many web container in the world but i choose tomcat as this tutorial since tomcat is quite easy to be understood and the server management is not that difficult. So for beginner, tomcat is a good kickstart to a real application server. For development, tomcat is a best friend since it has a very quick startup and it’s reliable for small number of applications.

INSTALLING TOMCAT 7.0

1. Download your Tomcat 7.0

Download the latest tomcat 7.0 in here.
Note : I prefer to use the distribution version one, so i recommend to choose any files except the installer version for windows since it is easy to be modified and to be moved to other computer.

2. Extract the downloaded file

Extract the file, then you will see a structure like this :

Folder Structure

After you finished this steps, you have succesfully installed your tomcat to your computer. Now let’s heading on the configuration.

CONFIGURING TOMCAT

1. Define administrator password

In tomcat, administrator term is defined as manager. In default, there will be no user in tomcat 7.0 as a manager. You have to add yours. To add new user, go to ${TOMCAT_INSTALLATION_DIR}/conf/ and open tomcat-users.xml.

At the first time you will see line 29 to 35 will be commented. Please uncomment these lines by removing tag. After that, add additional line for creating your user, and the code will be seen something like this :

<role rolename="tomcat"/>
<role rolename="role1"/>
<user username="tomcat" password="tomcat" roles="tomcat"/>
<user username="both" password="tomcat" roles="tomcat,role1"/>
<user username="role1" password="tomcat" roles="role1"/>
<user username="haka" password="haka" roles="manager-gui"/>

Note : Pay attention for the most bottom line. The username i set to “haka” and password set to “haka”. You can freely change these 2. But if you want the user to be manager, add manager-gui as the roles.

2. Configure local port

To configure any ports in Tomcat, go to ${TOMCAT_INSTALLATION_DIR}/conf/ and open file server.xml. After that, you can see whole configuration for server will be listed up there. For now, we will just customize port for host only. Go to line 67 in the file then you will see listing code like this :

You can change the port into any available port you like.
Note : If you have Oracle database installed, it might make a conflict since oracle listener use port 8080. So remember, if you have an oracle database installed, highly recommended that you change the port into other port, for example 8005, 8088, 8001, 8800,or whatever port you like ;). And also, you can change the connection timeout variable. This variable define how long will the system wait for starting the server. in this case, the value is 20000, means that the system will wait for 20 seconds IF the server is not tend to start.

I have oracle database installed in my current computer and i prefer port 8088, so that i change to port to 8088 :

<Connector port="8088" protocol="HTTP/1.1"
               connectionTimeout="20000" 
               redirectPort="8443" />

For a while, you have done with the minimum configuration for tomcat.

3. Starting the service

For starting the service, go to ${TOMCAT_INSTALLATION_DIR}/bin/ then execute file startup.bat. If everything is working fine, you will see a pop up uneditable command prompt windows like this :

Congratulations!! You have succesfully started your tomcat server :D

4. Accessing root directory in server

Go to your browser and type this :

http://localhost:8088/

The 8088 port is really depend on what port you set in the server.xml. If you use 8080, then you have to type localhost:8080, and so on. If it’s successful, then you will see display like this :

5. Administering your server

You have set your username and password for the manager. If you want to administer your server, go to http://localhost:8088/manager/html. Then a pop dialog will be prompted, requesting user name and password.

Enter your username and password (for my case, user is haka and password is haka). If it’s succesfull, the screen will drive you to the manager screen :

Tomcat Administration

You can customize your server, customize the application deployed and you can even deploy your web application via this screen.

That’s tutorial for beginners of Tomcat. Next time i will prepare the tutorial of how deploying your first java web application. Stay tune ;). God bless!

About these ads
 
13 Comments

Posted by on October 1, 2010 in English, Programming

 

Tags: , , , , , ,

13 responses to “Tomcat 7.0 for Beginners

  1. Peter Fred

    March 15, 2012 at 12:01 pm

    Thanks alot Hans Kristanto

     
  2. Daniel Eastland

    June 12, 2012 at 9:26 am

    Very useful. Thanks so much!

     
  3. Kazakh

    July 31, 2012 at 7:01 pm

    thanks

     
  4. bj

    August 5, 2012 at 2:09 am

    I’ve been trying to understand the Tomcat environment for about two weeks and this tutorial just gave me that “aha!” moment. Thank you very much.

     
  5. Cene

    August 11, 2012 at 2:56 pm

    Nice page to start up.

     
  6. soma

    September 28, 2012 at 11:12 pm

    very good page for starting with Tomcat…It helped me. Thanks.

     
  7. viji

    March 6, 2013 at 3:41 pm

    same here being trying for long..
    at last your tutorial helped!
    thnx alot

     
  8. satish

    May 12, 2013 at 1:39 am

    very good page for starting with Tomcat…It helped me. Thanks.

     
  9. michael

    September 1, 2013 at 9:02 pm

    Oracle listener port is 1526 not 8080

     
  10. Carmen

    September 10, 2013 at 11:25 am

    Thanks, your tutorial seems simple enough but I am not getting the same results as everybody else. I am following your steps, however, you don’t tell us what link to click on when we get to the tomcat download page. There are several links on that page, how is a total newbie supposed to know which one to select??? Would you mind helping me out futher?

    1.) Where is everybody seeing this ${TOMCAT_INSTALLATION_DIR}/conf/
    ${TOMCAT_INSTALLATION_DIR}/conf/
    ${TOMCAT_INSTALLATION_DIR}/bin/

    I don’t see this syntax/file strucure anywhere? Is this on a command line? Where is the ${}/foldername ? I’m sure I sound dumb to everybody, but I don’t understand.
    I have downloaded tomcat, and unzipped (I guess I did, because I see the same file structure as in your picture.)

    I don’t know where to find this ${TOMCAT_INSTALLATION_DIR}/conf/
    ${TOMCAT_INSTALLATION_DIR}/conf/
    ${TOMCAT_INSTALLATION_DIR}/bin/

    I am clicking on the conf and bin folders in windwos explorer and finding the xml files, but I am not seeing how to go to ${TOMCAT_INSTALLATION_DIR}/bin/ and ${TOMCAT_INSTALLATION_DIR}conf/ . I changed the port of 8088. I added myself as manager-gui, changed password and when I click startup.bat, I get a flashing command prompt(which is empty). I try to open tomcat start page in browser and this is the error I get: “Oops! Google Chrome could not connect to localhost:8088.”

    Again the tutorial seems simple enough, but it is not working and I don’t know what I am doing wrong. Would appreciate more details.

    Thanks!

     
  11. Hans Kristanto

    September 10, 2013 at 11:53 am

    Tomcat installation dir is where you install your tomcat. It can be at program files if you are usinh windows or /app if you use linux.

     
  12. Naren

    January 31, 2014 at 5:57 am

    nice …
    you forgot to mention that we have to set up CATALINA_HOME JAVA_HOME JRE_HOME paths in env variables

     
  13. Rahul

    February 17, 2014 at 11:53 am

    Thanks Hans.. That was really simple…

     

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

%d bloggers like this: