Build a server on your computer and publish your own website (for learning) involving peanut shells

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

1. Original Web site

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

2. Content

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, the PC 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 use the Tomcat server, if our Javaweb program has been deployed to the Tomcat server, in general, we have local access to the address: Localhost:8080/shop1,localhost refers to this machine, That is, the 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 conf folder, open the Server.xml file, and the section you want to modify is as follows:

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


The port from the original 8080 is modified to 80, because the HTTP protocol default port is 80, so you can no longer lose the port number, the docbase= "SHOP1" value to the name of your subordinate project, the default point to your project, This way 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 PlainCopy
    1. <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 to use the Internet access my website, sure enough, here we understand the truth can be, just learning test, so we use 8080 port.

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, Enter 192.168.1.1 (whichever is your route) in the browser and go to the Routing management page, such as:

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 am 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 after the start, will be the peanut shell service end of the IP data update 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.

Good luck, June!

Build a server on your computer and publish your own website (for learning) involving peanut shells

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.