How to change port 80 when binding multiple domain names to the Tomcat server in linux

Source: Internet
Author: User

First, you may need to purchase a domain name, and then manage the domain name, click "domain name resolution", add resolution,

Select A record and set the domain name to be resolved and the Internet IP address of your linux system.

The so-called top-level domain name is the domain name subject without a prefix (except www), such:

Http://pwdgame.com/

Http://www.pwdgame.com/

The so-called second-level domain name contains a prefix, such:

Http://cctv.pwdgame.com/

Http://china.pwdgame.com/

Second-level domain names are allocated based on top-level domain names. Without top-level domain names, there will be no second-level domain names. (The above is purely personal understanding)


Step 1:
Copy the entire webapp in the default tomcat directory.
Copy three copies to apply to three applications.
Then, put all your three application files under the root of the webapp (delete the original files first)

Such:

Webbench 1 \ ROOT Place your first website

Webbench 2 \ ROOTPlace your second website

Baidu_apps \ ROOT Place your third website


This is because you cannot directly configure the webapps/sub-directory in Tomcat. I tried to write sub-directories. Tomcat cannot find the absolute directory. Only the sub-directories above can be used, windows system does not try. (You can leave a message if you have a good method)


Step 2:

Use linux Command Line

# vim /apache-tomcat/conf/server.xml
/Apache-tomcat opens the directory for your Tomcat and press I to enter the editing mode. Press esc to exit the editing mode and enter the General mode.
Change the default tomcat port to 80
    <Connector port="80" protocol="HTTP/1.1"               connectionTimeout="20000"               URIEncoding="UTF-8"               redirectPort="8443" /> 

The default value is 8080, which does not include Character Set settings. You can also set it here.


Note that different hosts are different domain names.
AppBase is the webapp that you copy and re-Place your program to the root user.
<Engine name="Catalina" defaultHost="www.pwdgame.com">      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"             resourceName="UserDatabase"/>       <Host name="www.pwdgame.com" appBase="webapps1"  unpackWARs="true" autoDeploy="true" >            <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"               prefix="webapps1_access_log." suffix=".txt"               pattern="%h %l %u %t "%r" %s %b" />       </Host>      <Host name="bbs.pwdgame.com" appBase="webapps2"  unpackWARs="true" autoDeploy="true" >
      <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"               prefix="webapps2_access_log." suffix=".txt"               pattern="%h %l %u %t "%r" %s %b" />

 </Host> </Engine>

Press esc to exit the editing mode and press the button to enter

Save and exit

Restart Tomcat

# /apache-tomcat/bin/shutdown.sh# /apache-tomcat/bin/startup.sh
Open

Http://www.pwdgame.com/

Success !!!!!!


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.