Wednesday, February 6, 2013

Installing Apache Tomcat Server 7 on windows XP

The following steps need to be followed while installing Apache Tomcat Server 7:

Step1: Download the latest version of  Tomcat from http://download.cnet.com/Apache-Tomcat-32-bit/3000-10248_4-75734520.html  and extract the .zip file to any folder with directory C:\Program Files.

Step 2: Since the server needs Java Platform to work on set the environment variables for java.
             (a)Right click on My Computer and then select properties.
             (b)Then click on Environment Variables from the Advanced tab.
             (c)Under System variables click on new and set the variable name as JAVA_HOME and variable path as the directory in which your jdk file is stored.Then click OK.




* You can  check whether the variable is set or not using command prompt.open command prompt and type set JAVA_HOME  and hit enter.


 Step3:Configure Tomcat Server
           
Tomcat configuration files are located in the "conf" sub-directory of your Tomcat installed directory (e.g. "d:\myproject\tomcat\conf"). There are 4 configuration XML files:
  1. server.xml
  2. web.xml
  3. context.xml
  4. tomcat-users.xml
Make a backup of the configuration files before you proceed.
Step 3(a) "conf\server.xml" - Set the TCP Port Number
Use a programming text editor (e.g., NotePad++, TextPad) to open the configuration file "server.xml", under the "conf" sub-directory of Tomcat installed directory (e.g. "d:\myproject\tomcat\conf").
The default TCP port number configured in Tomcat is 8080, you may choose any number between 1024 and 65535, which is not used by an existing application. We shall choose 9999 in this article. (For production server, you should use port 80, which is pre-assigned to HTTP server as the default port number.)
<!-- Define a non-SSL HTTP/1.1 Connector on port 8080 -->
<Connector port="9999" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
Step 3(b) "conf\web.xml" - Enabling Directory Listing
Again, use a programming text editor to open the configuration file "web.xml", under the "conf" sub-directory of Tomcat installed directory.
We shall enable directory listing by changing "listings" from "false" to "true" for the "default" servlet. This is handy for test system, but not for production for security reasons.
<!-- The default servlet for all web applications, that serves static     -->
<!-- resources.  It processes all requests that are not mapped to other   -->
<!-- servlets with servlet mappings.                                      -->
<servlet>
  <servlet-name>default</servlet-name>
  <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
  <init-param>
    <param-name>debug</param-name>
    <param-value>0</param-value>
  </init-param>
  <init-param>
    <param-name>listings</param-name>
    <param-value>true</param-value>
  </init-param>
  <load-on-startup>1</load-on-startup>
</servlet>
Step 3(c) "conf\context.xml" - Enabling Automatic Reload
We shall add the attribute reloadable="true" to the <Context> element to enable automatic reload after code changes. Again, this is handy for test system but not for production, due to the overhead of detecting changes.
<Context reloadable="true">
   ......
</Context>
Step 3(d) "conf\tomcat-users.xml"
Enable the Tomcat's manager by adding the highlighted lines:
<tomcat-users>
  <role rolename="manager-gui"/>
  <user username="manager" password="xxxx" roles="manager-gui"/>
</tomcat-users>
Step 4: Starting Tomcat Server
type the following in Command Prompt







As soon as u hit enter the server starts.


To check if the server is ready to run,open your browser and type the following in the url:http://localhost:9999
Apache Tomcat homepage will be displayed!


No comments:

Post a Comment