Web application-Configure a virtual host (build a Web site) __web

Source: Internet
Author: User
Tags tomcat server

Recently learned some new technology, is about the web development, is how to configure the virtual host, that is how to build a Web site.

Download and install the Tomcat server first, then store your own Web application on your own computer, for example, by writing an HTML file: index.html. The storage path is d:\sina\mail\index.html, and the contents of the file are, of course, casually written.

Then start configuring the virtual host;

Here's what you need to say about the directory structure of the Tomcat server (as shown in the figure):













And the directory where the Web application resides:

For example, we want to create a virtual host for the Web application we just created, as follows: Open the Tomcat server directory conf, open the Server.xml file, there is a host tag inside, we add a host tag inside:

      

If you have just started a Tomcat server, you will need to reboot the server after you have changed the Server.xml file. In addition, we need to make some settings on our own computers.    Open path C:\Windows\System32\drivers\etc; Inside there is a Hosts file, open and then for example after adding a host name and its own computer IP address mapping such as: 192.168.1.53 www.sina.com.cn;

Then enter the address in the browser: http://www.sina.com.cn:8080/mail/1.html can access their Web applications, and the port number can not write, but need to set 80 in the Server.xml file port;

Two

Of course we can just type in http://www.sina.com.cn to access our web apps: We need to specify the default directory, That is, put the value of path in the label we just added in the server.xml file to null, and then create a new folder in the Mail folder named Web-inf, which creates a Web.xml file, which is written in the following file:

<?xml version= "1.0" encoding= "iso-8859-1"?> <web-app xmlns=


"Http://java.sun.com/xml/ns/javaee"
  Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemalocation= "http://java.sun.com/xml/ns/ Java EE
                      http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd "
  version=" 3.0 "> 
  
  
   <welcome-file-list >
        <welcome-file>index.html</welcome-file>
    </welcome-file-list>

</web-app >
On the 2nd I did not succeed because the port is set to 80, which means that the input http://www.sina.com.cn access is not successful and may be limited by the security issues of the DNS. You can only http://www.sina.com.cn:8080 access to our own Web applications. In addition, through this method can also help to play the game's peers to solve the problem of plug-in upgrade, just to upgrade the designated server designated as their own host on the line.

Okay, that's it. Complete the configuration of the virtual 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.