Build a server on your computer and publish your own website

Source: Internet
Author: User
Tags buy domain buy domain name

We usually learn to write a javaweb program, we in order to more close to the reality, think of their own Javaweb program published, the outside network of students can visit our website, we go to buy space, to buy domain name it, in fact, there is no need, we just study, testing, Setting up a server on your own computer can meet the requirements. The last blog post, thePC server and the Android client to achieve network communication, is to use this principle.

We are divided into three steps to achieve:(I use the example javaweb program is my own simple to write a small program SHOP1)

1,

We useTomcat server, if ourJavaweb Program has been deployed to the Tomcat server, generally our local access address is : localhost:8080/shop1,localhost refers to this machine, that is, 127.0.0.1, 8080 port number,SHOP1 the project name you deployed, but it's too cumbersome, we just want to access our project via IP address, i.e. 127.0.0.1 or localhost, we just need to modify the Tomcat configuration, Open the directory where Tomcat is located, open the conf folder, open the server.xml file, and the section you want to modify is as follows:

[Plain]View Plaincopyprint?
    1. <connector port= "protocol=" http/1.1 "
    2. connectiontimeout= "20000"
    3. redirectport= "8443"/>
    4. <context path= "" docbase= "Shop1" reloadable= "true"/>
<connector port= "protocol=" http/1.1 "               connectiontimeout=" 20000 "               redirectport=" 8443 "/> < Context path= "" docbase= "Shop1" reloadable= "true"/>

The port will be changed from the original 8080 to 80, because the HTTP protocol default port is 80, so you can no longer lose the port number, the docbase= "SHOP1" The value is changed to the name of the project you are subordinate to, by default pointing to your project so that you can not lose the name of the project.

Also note that the version of Tomcat 7.0 in the server.xml file is not actually

[Plain]View Plaincopyprint?
    1. <context path= "" docbase= "Shop1" reloadable= "true"/>
<context path= "" docbase= "Shop1" reloadable= "true"/>

This article, and downloaded a 5.0 version of incredibly have, if you do not, copy add in it.

OK, so you can access your project by typing localhost in the browser!

PS: In order to come down to work do not appear what problem, I did not change 8080 port to 80, it is said that 80 port was sealed off by telecommunications, I let the students access my web site with the telecommunications network, really do not, here we understand the truth can be, just learning test, so we use 8080 ports.

2,

In the previous step we only achieved their own access, but how to let the outside network of students access, here may involve a simple network knowledge, I am not very good network learning. That's a little more popular. There are two situations (1) You do not use the Internet route, the operator to give you a separate IP address, then you can directly use your IP to let the classmate of the network to visit your site, we use the 8080 port, so the form is:XX. Xx. Xx. xx:8080. In order to let more students understand, I am wordy, how to know their IP address, you do not have to use the cmd command line input ipconfig this slightly professional method to obtain, in fact, as long as Baidu search "IP Query", the first one is.

(2) using a router, a router with several computers, such as with roommates, which requires you to go to the Routing Management page to set up, port mapping, let others access your IP address, map to your computer, in the browser input 192.168.1.1 (whichever is your route), go to the Routing Management page and operate as follows:

Forwarding rules -----Virtual Server -------Add new entries

Port we did not change, so fill 8080,IP address for your computer in the local area network address, how to know their local area network address, very simple Baidu a bit, as long as the LAN computer is not too much, generally 192.168.1.XXX, I here for 192.168.1.101, then click Save,OK, and then the network can use your IP to visit your website!

I have the following:

At this point you can send this URL to your classmates, try, he can visit your site, the answer is YES!

3,

But there are new problems, the next day you open the route, or the internet again, the operator will be reassigned to you a new IP address, do you let your classmate visit, the IP address sent to him again? Obviously this is unreasonable.

At this point, we want to have a dynamic domain name how good. Here to introduce a software "peanut shell", download and install, and then register, you will get a free two-level domain name, each boot from the start, will be the Peanut Shell server IP data updated to your new IP address, and then every time you use your fixed domain name to access, will be resolved to your new IP address.

Such as:

Double-click your domain name to see if it shows "detected, your domain is activated and pointing to the right"!

OK, here, no routing students, you can directly use your domain name to access!

There are routes to the classmate, but also to operate a step more:

Once again, proceed to the Routing management page, such as:

Click on "Dynamic DNS", then if you do not have a problem with the above, the service provider that column has been automatically populated with the Peanut shell URL, and then enter the user name, password, click Login, if shown as "connection Success", then click "Save".

Here, finally done, look at the final:

As you can see, I have successfully accessed my site using my domain name.

PS: Sometimes show "verification success" is also an illusion, a click on the "Save", also displayed as "verification failed", and then click "Login", multiple clicks "Save", until it has been shown as "verification success", anyway, is to try a few more times.

zz:http://blog.csdn.net/pzhtpf/article/details/7704337

Build a server on your computer and publish your own 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.