Detailed description of Tomcat website publishing configuration Scheme

Source: Internet
Author: User

Modify the port, modify the default release directory, and bind multiple domain names

1. Modify the release port to 80 (Tomcat is 8080 by default)
 
Open the configuration file (E: \ J2EEServer \ Tomcat 6.0 \ conf \ server. xml) and find:
Copy codeThe Code is as follows:
<Connector port = "8080" protocol = "HTTP/1.1"

MaxThreads = "150" connectionTimeout = "20000"

RedirectPort = "8443" type = "regxph" text = "yourobjectname"/>
<Connector port = "8080" protocol = "HTTP/1.1"

MaxThreads = "150" connectionTimeout = "20000"

RedirectPort = "8443" type = "regxph" text = "yourobjectname"/>

After modification:

Copy codeThe Code is as follows:
<Connector port = "80" protocol = "HTTP/1.1"

MaxThreads = "150" connectionTimeout = "20000"

RedirectPort = "8443" type = "regxph" text = "yourobjectname"/>
<Connector port = "80" protocol = "HTTP/1.1"

MaxThreads = "150" connectionTimeout = "20000"

RedirectPort = "8443" type = "regxph" text = "yourobjectname"/>

In fact, you can change port: 8080 to port: 80. Other parameters remain unchanged. In this way, the client can directly enter the IP address or domain name when accessing the server.

2. Modify tomcat Character Set
 
You should have encountered Chinese garbled characters in writing programs. In addition to ensuring the consistency of the character sets of pages and databases, you must note that the character set of tamcat is used. Sometimes check the process sequence from start to end and find that the program is normal, but there are garbled characters. Check the Tomcat character set! Find E: \ Tomcat 6.0 \ conf \ server. xml:

Copy codeThe Code is as follows:
<Connector port = "80" protocol = "HTTP/1.1"

MaxThreads = "150" connectionTimeout = "20000"

RedirectPort = "8443" type = "regxph" text = "yourobjectname"/>
<Connector port = "80" protocol = "HTTP/1.1"

MaxThreads = "150" connectionTimeout = "20000"

RedirectPort = "8443" type = "regxph" text = "yourobjectname"/>

After modification:
Copy codeThe Code is as follows:
<Connector port = "80" protocol = "HTTP/1.1"

MaxThreads = "150" connectionTimeout = "20000"

RedirectPort = "8443" URIEncoding = "UTF-8"/>
<Connector port = "80" protocol = "HTTP/1.1"

MaxThreads = "150" connectionTimeout = "20000"

RedirectPort = "8443" URIEncoding = "UTF-8"/>

3. Modify the tomcat publishing path (default path: E: \ J2EEServer \ Tomcat 6.0 \ webapps \ ROOT)
Open the configuration file (in E: \ J2EEServer \ Tomcat 6.0 \ conf \ server. xml) and find:
Copy codeThe Code is as follows:
<Engine name = "Catalina" defaultHost = "localhost">

<Host name = "localhost" appBase = "webapps"

UnpackWARs = "true"

XmlValidation = "false" xmlNamespaceAware = "false">

</Host>

</Engine>
<Engine name = "Catalina" defaultHost = "localhost">

<Host name = "localhost" appBase = "webapps"

UnpackWARs = "true"

XmlValidation = "false" xmlNamespaceAware = "false">

</Host>

</Engine>

Add the following labels between Copy codeThe Code is as follows:
<Context path = "" docBase = "photo" debug = "0" reloadable = "true"/>
<Context path = "" docBase = "project path" debug = "0" reloadable = "true"/>

Path indicates the name of the virtual directory. If you only need to enter the IP address to display the home page, the key value is left blank;

DocBase is the path of the virtual directory, which defaults to the $ tomcat/webapps/ROOT directory. Now I have created a photo directory under the webapps directory to make it my default directory. Both debug and reloadable are set to 0 and true respectively.

In this way, when accessing the server, find the page under $ tomcat/webapps/photo ~~~~~

 

3. bind multiple domain names
 
Open the configuration file (My: D: \ Program Files \ Tomcat \ conf \ server. xml) and find:
Copy codeThe Code is as follows:
<Engine name = "Catalina" defaultHost = "localhost">

<Host name = "localhost" appBase = "webapps"

UnpackWARs = "true"

XmlValidation = "false" xmlNamespaceAware = "false">

</Host>

</Engine>
<Engine name = "Catalina" defaultHost = "localhost">

<Host name = "localhost" appBase = "webapps"

UnpackWARs = "true"

XmlValidation = "false" xmlNamespaceAware = "false">

</Host>

</Engine>

Solution 1: multiple projects are under different directories.

Copy codeThe Code is as follows:
<Engine name = "Catalina" defaultHost = "pic.jb51.net">

<Realm className = "org. apache. catalina. realm. UserDatabaseRealm"

ResourceName = "UserDatabase"/>



<Host name = "xixi.jb51.net" appBase = "abcapps"

UnpackWARs = "true"

XmlValidation = "false" xmlNamespaceAware = "false">

</Host>
<Engine name = "Catalina" defaultHost = "pic.jb51.net">

<Realm className = "org. apache. catalina. realm. UserDatabaseRealm"

ResourceName = "UserDatabase"/>

 

<Host name = "xixi.jb51.net" appBase = "abcapps"

UnpackWARs = "true"

XmlValidation = "false" xmlNamespaceAware = "false">

</Host>

 
<Host name = "haha.jb51.net" appBase = "D: \ Program Files \ Tomcat \ test"

UnpackWARs = "true"

XmlValidation = "false" xmlNamespaceAware = "false">

</Host>



<Host name = "lala.jb51.net" appBase = "webapps"

UnpackWARs = "true"

XmlValidation = "false" xmlNamespaceAware = "false">

</Host>

</Engine>
<Host name = "haha.jb51.net" appBase = "D: \ Program Files \ Tomcat \ test"

UnpackWARs = "true"

XmlValidation = "false" xmlNamespaceAware = "false">

</Host>

 

<Host name = "lala.jb51.net" appBase = "webapps"

UnpackWARs = "true"

XmlValidation = "false" xmlNamespaceAware = "false">

</Host>

</Engine>

Add the following content to the hosts file in C: \ WINDOWS \ system32 \ drivers \ etc:

127.0.0.1 xixi.jb51.net

127.0.0.1 lala.jb51.net

127.0.0.1 haha.jb51.net

Follow the preceding Configuration:

1. http://xixi.jb51.net access the website under $ {tomcat} \ abcapps \ ROOT

2. http://haha.jb51.net access the website under D: \ Program Files \ Tomcat \ test \ ROOT

3. http://lala.jb51.net access the website under $ {tomcat} \ webapps \ ROOT.

Engine dafaultHost: indicates the default host to access tomcat. Note that it cannot be localhost. Otherwise, the tomcat management interface is displayed by default when others access tomcat through your ip address.

Host name: indicates the domain name bound to the Host. If localhost is bound, you can enter localhost in the browser to access the Host.

Host appBase: indicates the file storage path bound to the Host. You can use the relative or absolute path.

 
Solution 2: multiple projects are under the same directory of webapps, Which is configured with <Context> in different

Copy codeThe Code is as follows:
<Engine name = "Catalina" defaultHost = "xixi.jb51.net">

<Realm className = "org. apache. catalina. realm. UserDatabaseRealm"

ResourceName = "UserDatabase"/>



<Host name = "xixi.jb51.net" appBase = "webapps"

UnpackWARs = "true"

XmlValidation = "false" xmlNamespaceAware = "false">

<Context path = "" docBase = "test1" debug = "0" reloadable = "true"/>

</Host>



<Host name = "haha.jb51.net" appBase = "webapps"

UnpackWARs = "true"

XmlValidation = "false" xmlNamespaceAware = "false">

<Context path = "" docBase = "test2" debug = "0" reloadable = "true"/>

</Host>



<Host name = "lala.jb51.net" appBase = "webapps"

UnpackWARs = "true"

XmlValidation = "false" xmlNamespaceAware = "false">

<Context path = "" docBase = "test3" debug = "0" reloadable = "true"/>

</Host>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.