Tomcat configuration skills Top 10 list

  Abstract: Tomcat configuration skills Top 10 list 

  <tr> <td> 

  1, configuration management system (Admin Web Application) 

  Most of the commercial J2EE servers provide a powerful management interface, and easy-to-understand most used Web application interface.    Tomcat according to its own methods, and also provides a mature management tool, and in no way comparable to those of commercial competitors.    Tomcat the Admin Web Application first appeared in the 4.1 version that includes the functions of the management context, data source, such as user and group.    Of course management can be as initialization parameters, user, group, the role of a variety of database management.    In the follow-up version, these functions will be greatly expanded, but the existing functional very practical.    Admin Web Application deployment is defined in the automatic document: CATALINA_BASE / webapps / admin.xml.    (Translator Note: CATALINA_BASE that tomcat server installation directory under the directory) 

  You must edit this file to determine the docBase Context parameter is the absolute path.    In other words, CATALINA 

  _BASE / Webapps / admin.xml path is the absolute path.    As an alternative, you can automatically delete the deployment of this document, and in the establishment of a document server.xml Admin Web Application of context, the effect is the same.    You can not manage Admin Web Application this application, in other words, apart from removing CATALINA_BASE / webapps / admin.xml, you may not do anything. 

  If you use UserDatabaseRealm (default), you will need to add a user and a role to CATALINA_BASE / conf / tomcat-users.xml file.    You edit this file, add a name of "admin" to the role in the document, as follows: 

  The same need for a user, and this user's role is "admin."    As the user, add a user (change their passwords more secure): 

  Password = "deep_dark_secret" 
  Roles = "admin" /> 

  After you have completed these steps, please restart Tomcat, http://localhost:8080/admin visit, you will see a login interface.    Admin Web Application based on container security management mechanism, and adopted the Jakarta Struts framework.    Once you as "admin" role of the user management interface, you will be able to use the management interface configuration Tomcat. 

  2, configuration management application (Manager Web Application) 

  Manager Web Application you through a Admin Web Application more than a simple user interface, the implementation of some simple Web application tasks.    Manager Web Application been defined in the deployment of an automated document: 

  CATALINA_BASE / webapps / manager.xml 

  You must edit this file to ensure that the context of the docBase parameter is the absolute path, that is to say CATALINA_HOME / server / webapps / manager of the absolute path.    (Translator Note: CATALINA_HOME that tomcat installation directory) 

  If you are using the UserDatabaseRealm, then you need to add a role and a user to CATALINA_BASE / conf / tomcat-users.xml file.    Next, edit this file, add a "manager" to the role of the document: 

  The same need to have a role as "manager" of users.    As has been the user, add a new user (to change passwords more secure): 

  Password = "deep_dark_secret" 
  Roles = "manager" /> 

  And restart Tomcat, visit http://localhost/manager/list will see a very simple text-based management interface, or visit http://localhost/manager/html/list, will see a HMTL management interface .    In either way to show your Manager Web Application now been launched. 

  Manager application allows you to privileges in the absence of systems management on the basis of the installation of a new Web application to be used for testing.    If we have a new web application in / home / user / under hello, and want to install it into / hello, and in order to test the application, we can do so, in a file box "/ hello" ( as a visit to the path), in the second text box "file: / home / user / hello" (as Config URL). 

  Manager application also allows you to stop and restart, remove and re-deployment of a web application.    An application that they were unable to stop the visit, when users try to access the application of the suspension, will see a 503 error? "503 - This application is not currently available." 

  Remove a web application, only to run from the Tomcat to delete the copy of the application, if you restart Tomcat, the application will be removed again (that is, remove from the hard drive does not mean deleted). 

  3, the deployment of a web application 

  There are two ways the system can be deployed web services. 

  1. WAR copy of the document you or your web application folders (including all the elements of the web) to $ CATALINA_BASE / webapps directory. 

  2. Your web services only, including the establishment of a context of XML content paper clips, and the paper put $ CATALINA_BASE / webapps directory.    The web application itself can be stored on the hard drive anywhere. 

  If you have a WAR file, you deployment if it is only necessary to simply copy the document to CATALINA_BASE / webapps directory can be, the paper must be. "War" as the extension.    Once Tomcat listening to this document, it (the default) untie the package as a subdirectory, and file name WAR document as a subdirectory name. 

  Next, the Tomcat will be in memory of the establishment of a context, as if you server.xml file in the same establishment.    Of course, the other necessary elements, will be server.xml in DefaultContext. 

  Application deployment of the web is another way to write a fragment Context XML document, and then copy the document to CATALINA_BASE / webapps directory.    Context is not a fragment of a complete XML document, but rather a context elements, as well as the application of the corresponding description. 

  This document is like clips from the server.xml cut out in the context of the same elements, such fragments were named as the "context clips." 

  For example, if we want to deploy a named MyWebApp.war applications, the use of the application realm as access control, we can use this clip: 

  The fragment of the name "MyWebApp.xml", and then copied to CATALINA_BASE / webapps directory. 

  This context clips provide a convenient way to deploy web applications, you do not need to edit server.xml, unless you want to change the default deployment characteristics, the installation of a new web application does not need restart Tomcat. 

  4, virtual host configuration (Virtual Hosts) 

  About server.xml "Host" elements, you set up only in the virtual host only needs to be revised.    Virtual Console is a web server in a number of domain name service mechanism for each domain name, all seem to enjoy the entire mainframe.    In fact, the majority of small business websites are using virtual console to achieve, and this is mainly because the Virtual Console can directly connect to the Internet and provide the appropriate bandwidth, in order to protect the reasonable response speed access, and virtual console can provide a stable fixed IP. 

  Based on the name of the Virtual Console can be built on any web server, is the method adopted by the domain name server (DNS) on the alias IP address, and told to go to the web server at the request of different domain names circulated to the appropriate page directory.    This article is mainly because the speakers Tomcat, we are not prepared in a variety of operating systems on the DNS settings, if you need help in this regard, please refer to the "DNS and Bind," a book, the author is Paul Albitz and Cricket Liu ( O'Reilly).    In order to facilitate demonstration, I will use a static host document, because this is the most simple test method alias. 

  Tomcat in the use of virtual console, you need to set DNS or mainframe data.    To test for the establishment of a local IP IP alias enough, the next, you will need to add a few lines server.xml content, as follows: 

  Shutdown = "SHUTDOWN" debug = "0"> 

  "Org.apache.coyote.tomcat4.CoyoteConnector" 
  Port = "8080" 
  MinProcessors = "5" maxProcessors = "75" 
  EnableLookups = "true" 
  RedirectPort = "8443" /> 
  "Org.apache.coyote.tomcat4.CoyoteConnector" 
  Port = "8443" minProcessors = "5" 
  MaxProcessors = "75" 
  AcceptCount = "10" debug = "0" 
  Scheme = "https" secure = "true" /> 
  DefaultHost = "localhost" debug = "0"> 

  Tomcat the server.xml documents in the initial state, only include a virtual console, but it easily expanded to support multiple virtual console.    In the case of the front display is a simple server.xml version, which is used to add bold part of a virtual console.    Host each element must include one or more elements of context, contains elements of the context is the need for a default context, the context of the show that the default path should be empty (for example, the path = ""). 

  </ Td> </ tr> </ table> 
  ↑ Back 

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Facebook
  • DotNetKicks
  • DZone
  • Netvouz
  • Propeller

Tags: ,

Releated Java Articles

Comments

Leave a Reply