Tomcat ropes, deploying static Web sites, multi-port access

Source: Internet
Author: User
Tags server port tomcat
installation

Download the Tomcat compression pack:
https://tomcat.apache.org/download-80.cgi

After decompression, the following:

1. Start Tomcat

#先给bin目录可执行权限
sudo chmod-r 777 bin/
#然后到bin目录下执行
./startup.sh start

After launch, we use a browser to access: http://localhost:8080
8080 is the default port for Tomcat.
You will see a page like this:

This means that our tomcat, the Web server, started successfully and has a default Web site.

2. Default Web site

WebApps root is the default Web site root directory, the index.jsp is the page file we visited above.

3. Stop Tomcat

./shutdown.sh
Configuration

The Conf directory contains the basic configuration of Tomcat

First look at server.xml This configuration file, which is a global configuration file.

<?xml version= "1.0" encoding= "UTF-8"?>
<server port= "8005" shutdown= "Shutdown" > ...
  <service name= "Catalina" >
       <connector port= "8080" protocol= "http/1.1"
               connectiontimeout= "20000"
               redirectport= "8443"/>
       <engine name= "Catalina" defaulthost= "localhost" >
             

The outermost layer is the SERVER:SHUTDOWNTOMCAT support remote shutdown;
Service node, you can create multiple;
There are multiple connector in the service, and this connector controls how the client connects to the server (http/1.1);
Host node, configure the root directory is WebApps, if we create a mytest/index.html in WebApps, then can be accessed through http://localhost:8080/mytest/index.html;

Just this path, can also be configured, in the <Host> node configuration <Context>

<context path= "abc" docbase= "MyTest"/>

Modify the configuration and remember to restart Tomcat
And then you can access this: http://localhost:8080/abc/index.html

<context path= "" docbase= "MyTest"/>

Even this access: http://localhost:8080/index.html modify Tomcat's web directory

   

The default Web directory is the WebApps in the Tomcat package and can be modified to a different path.
For example, I changed to this address:

    

As required by Tomcat, you also need to create a directory called Root to put the Web page in.
This way, accessing http://localhost:8080 is the Web page we just created.

Remember to change the configuration to restart the Tomcat multi-port

Simply put <Service> in a

  <service name= "Catalina2" >
       <connector port= "8088" protocol= "http/1.1" connectiontimeout= "20000" redirectport= "8443"/>
        <engine name= "Catalina2" defaulthost= "localhost" >
             

This service I specified the port is 8088, and then we visit http://localhost:8088, which is indeed AppBase's website.

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.