Detailed explanation of the WEB server of IIS (below)


foreword

In the previous blog, we have downloaded the IIS-WEB plug-in on the server, which contains the default website, which is equivalent to making a simple WEB website. Today I will introduce how to configure and publish your own website, and continue to upgrade and optimize the configuration on the basis of the WEB server.


1. How to publish your own website on the server

We disabled the original default website before, as shown below

insert image description here

Next, you need to create your own website, the steps are as follows:

  1. Right-click [ Site ], click [ New ], click [ Site ]

insert image description here

  1. Click [ Next ]

insert image description here

  1. Write the description here by yourself, I will write xiaoshiyi , and the written description information will be displayed inThe area selected on the left, and then click [ Next ]

insert image description here

  1. On this page, the website port is 80 , which has been written by default here. The above [ website IP address ] means:Which IP is used by others to visit your website; There is a [ All Unassigned ] in it, which means that there is more than one IP on the server. For example, I can configure two or three IPs on this server. It's ok if sayThere are multiple network cards on my server, and each network card is connected to a switch, so there are multiple IPs. At this time, it is necessary to specify that the client isThrough which IPOnly by entering my server can I visit my newly created website. If [ all unallocated ] is written here , it means that the client accesses theany IPYou can see my website.

insert image description here

  1. But it doesn’t make any sense to choose [ All Unassigned ] now , because my current server only has one IP 10.1.1.2 , just select it, and then click [ Next ]

insert image description here

  1. Here, the path to the home directory refers to ourThe file path where the webpage to publish is located, then we have to click [ Browse ] on the right to find the file directory where the webpage to be published is located.

insert image description here

Here comes the question: Have we not written a webpage yet, so cancel the creation wizard here first, and go back to the computer to create a website. For the website, we will make it on the D drive . The steps are as follows:

  1. Right-click any blank space, select [ Folder ] in the pop-up drop-down list , and create a new folder. The name is the name of our website, called xiaoshiyi

insert image description here

  1. After creating this folder, justIndicates that a website has been created, but it is still empty, there is no web page, we need to write a web page

insert image description here

  1. Go to the xiaoshiyi folder and start creating a web page, right-click on the blank space, select [ New ], and select [ Text Document ]

insert image description here

  1. The name of the webpage is in front of the text document . Note: if this webpage is the core of our entire website, that is, the homepage, thenprofessional nameIt is named index , if you must choose another name. There are two ways to write the following extension: one is htm , the other is html ,The latter is the most standard. Press Enter after modification, a dialog box appears, click [ Yes ]. This page is ready, but there is no content in it

insert image description here

  1. We are now going to enter the web page to edit the content, right-click the file, select [ Open with ], select [ Notepad ], and use Notepad to open and write

insert image description here

  1. Enter it and start writing html code. Here I will directly write a piece of code and put it in. As for the friends who are not familiar with the front-end code, I will talk about the front-end grammar later. After writing, press Ctrl + S to save, then close Notepad

insert image description here

  1. Double-click to open the file to see the effect of the webpage. The title is at the top of the webpage, and the content of the text we wrote is inside.

insert image description here

Now that the website has been written, we have to publish it, or go back to the step of [ Enter the main directory path ] just now, click [ Browse ], find the xiaoshiyi folder we just created , which is the site of our website, and then Click [ Next ]

insert image description here

This interface is to choose to set access permissions for users . Users only need to access the webpages we have written, and they don’t need to make changes, so only [ read ] is enough, and what we are currently writing is only static webpages, and we do not communicate with users. In the place of interaction, the following permissions are not used, and then click [ Next ]

insert image description here

Click【Finish

insert image description here

After the creation is complete, you can see that in addition to the [ default website ], there is an additional website [ xiaoshiyi ], and now port 80 is open

insert image description here

We go back to the XP computer, open the IE browser, enter the URL 10.1.1.2 , and press Enter, you can see

insert image description here

An error is reported, and access is prohibited. What is the problem? To teach you how to solve it, go back to the 2003 server, right-click [ xiaoshiyi ], and click [ Properties ] in the pop-up drop-down list

insert image description here

Click [ Document ] in it , this page means to tell the user,Which is the home page in my website. You can see that there is no index.html in it , so you need to add it manually, click [ Add ]

insert image description here

Enter index.html and click [ OK ]

insert image description here

Click 【Move Up】to push the page to the top

insert image description here

After pinning, click [ OK ]

insert image description here

Now go back to the XP computer, open the browser, enter 10.1.1.2 , and press Enter, you can see that it is successful

insert image description here

Let's go back to the 2003 server, open the D drive, open the xiaoshiyi folder, and create a new webpage in it, named fruits

insert image description here

Right-click the file, and click [ Edit ] in the pop-up drop-down list

insert image description here

Write the content as follows, click Ctrl + S to save, and then close Notepad

insert image description here

Although there are two webpages now, when the customer visits 10.1.1.2 , what he sees is the webpage of xiaoshiyi just now . Let’s go back to XP and open the browser, enter the IP 10.1.1.2 , and press Enter to see

insert image description here

If we need to use the fruits page as the homepage, follow the operation just now, enter [ Properties ], open [ Documents ], add fruits.html to it, put it on top, and click [ OK ]

insert image description here

Go back to XP, open the browser, enter IP 10.1.1.2 , press Enter, you can see

insert image description here

The above is the first experiment we did, publishing our own website on the server. Next, we will do a second experiment, creating and publishing a website on the server. If a server only publishes one website, it is a waste of resources.

2. How to publish multiple websites on the same server

Above we made an official website. If the company wants to publish another business system, internal employees can log on to upload and download some data for use intransaction processing. I won’t continue to write the webpage here, I have prepared the webpage file and copied it directly to the D drive on the 2003 server

insert image description here

Open the login folder and you can see the following picture

insert image description here

Next, we will publish the login website to the server, and the 1.html page inside ishome page of the site. Proceed as follows:

  1. Enter the 2003 server, open the IIS software, right-click [ Website ], click [ New ], click [ Website ]

insert image description here

  1. Click [ Next ]

insert image description here

  1. Just write login as the website description , and click [ Next ]

insert image description here

  1. The IP here is still 10.1.1.2 , although it has been used once before, it does not matter, click [ Next ]

insert image description here

  1. Click [ Browse ] to find the login folder in the D drive and select it, and click [ Next ]

insert image description here

  1. Click [ Next ]

insert image description here

  1. Click【Finish

insert image description here

You can see that the login website has been created, as shown below

insert image description here

But the status is [ Stop ], right-click login , and click [ Start ] in the drop-down list

insert image description here

As a result, the following pop-up window pops up, prompting that your port number has been occupied by another site, that is, it is occupied by xiaoshiyi . This means that each website is bound to an IP and port number, telling the user that port 80 on my network card 10.1.1.2 is bound to the xiaoshiyi website.

insert image description here

What should we do in this situation? There are two methods, the first method :Install another network card for this 2003 virtual machine,Proceed as follows:

  1. Right-click [ My Network Places ], and click [ Properties ] in the drop-down list

insert image description here

  1. Right-click [ Local Area Connection ], click [ Properties ] in the drop-down list

insert image description here

  1. Double-click to open [ Internet Protocol (TCP/IP) ]

insert image description here

  1. Click [ Advanced ]

insert image description here

  1. Click【Add

insert image description here

  1. Write 10.1.1.3 for the IP address and 255.255.255.0 for the subnet mask , and click [ Add ]

insert image description here

  1. Click [ OK ], a total offour times sure, IP configuration is complete

insert image description here

  1. After configuration, verify, enter the console with cmd, enter the command: ipconfig , press Enter, and you can see that there are two IPs: 10.1.1.2 and 10.1.1.3 . That is, if you visit any of these two IPs, you can access my server

insert image description here

  1. Go back to the IIS software, right-click login , and click [ Properties ] in the pop-up drop-down list

insert image description here

  1. Click the drop-down icon behind the IP address, select 10.1.1.3 , and click [ Apply ] to change the IP bound to the login website to 10.1.1.3

insert image description here

  1. Click [ Documents ], click [ Add ]

insert image description here

  1. Fill in 1.html and click [ OK ]

insert image description here

  1. Click [ Move Up ], put 1.html on top, and then click [ OK ], and the home page is also set

insert image description here

  1. Then right-click login , and click [ Start ] in the pop-up drop-down list

insert image description here

  1. It can be seen that the startup is successful

insert image description here

  1. Go back to the XP computer, open the browser, enter the address 10.1.1.3 , and press Enter, you can see the very beautiful employee login page as shown below

insert image description here

  1. Then open the browser and enter the address 10.1.1.2 , press Enter to see

insert image description here

Now both websites can be accessed successfully, the one just used isadd IPThe method is more troublesome, now try the second method ,The IP remains the same, but the port number is changed,Proceed as follows:

  1. Go back to the 2003 server, come to the IIS software, right-click login , and click [ Properties ] in the drop-down list

insert image description here

  1. Click the drop-down icon on the right side of the IP, select the IP as 10.1.1.2 , and change the port number to 8000 . Note here: In principle, as long as the port number is not 80, it is fine, but engineers generally change it to 8080 or 8000 , etc.four digit port number, it is not recommended to use port numbers within 1000 such as 81 and 82, becausePort numbers within 1000 have been reserved internationally, click [ OK ] after modification

insert image description here

  1. Verify after the modification, enter the console with cmd, enter the command: netstat -an , press Enter to see the following picture, not only port 80 is opened on my server , but also port 8000 is opened

insert image description here

  1. Then go back to the XP computer, open the browser and enter 10.1.1.2 , and press Enter to see that the xiaoshiyi website is displayed normally

insert image description here

  1. You can see the xiaoshiyi website directly by entering the IP just now , because the default port 80 is used , so you don’t need to write the port number , now add the port number 8000 after 10.1 . The login website is also accessed successfully

insert image description here

Now we publish multiple sites on the same server, two methods are introduced: 1.Different IP, same port number;2. Same IP, different port number. But these two methodsOnly for testing, not suitable for actual production use, because no matter which method will bring inconvenience to customers, the first method customers need to remember multiple IPs, and the second method customers need to remember multiple port numbers.

Now I will teach you the third method , borrowing the DNS domain name resolution method introduced earlier, we can make the IP and port of the two sites the same, but give them twoBind different domain names, that isBind to a different hostname. Those who have read the blogger’s previous blog should remember what I said, baidu.com in www.baidu.com is the domain name, and the www in front is the host name. Now we start to do this experiment, the steps are as follows:

  1. On the 2003 server, click [ Start ] in the lower left corner, click [ Administrative Tools ], and click [ DNS ]

insert image description here

  1. Enter the DNS software, right-click [ Forward Lookup Zone ], click [ New Zone ]

insert image description here

  1. Click [ Next ]

insert image description here

  1. Click [ Next ]

insert image description here

  1. Write xiaoshiyi.com as the name , and click [ Next ]

insert image description here

  1. Click [ Next ]

insert image description here

  1. Click [ Next ]

insert image description here

  1. Click【Finish

insert image description here

  1. Follow the same method above to create a new [ Forward Lookup Zone ] named login.com , and the others are the same, so we won’t demonstrate it anymore. After it is built, it will be shown in the figure below:

insert image description here

After the zone is created, create a new host, the steps are as follows:

  1. Right-click xiaoshiyi.com , and click [ New Host ] in the drop-down list

insert image description here

  1. Write www for the host name , write the address of this server 10.1.1.2 for the IP address , click [ Add Host ], click [ OK ] in the pop-up window , and then click [ Finish ]

insert image description here

  1. Then right-click login , and click [ New Host ] in the pop-up drop-down list

insert image description here

  1. The host name is still www , the IP address is still 10.1.1.2 , click [ Add host ], click [ OK ] in the pop-up window , and then click [ Finish ]

insert image description here

Now the two parsing areas and hosts have been newly created

insert image description here

Let's go back to the XP computerLet its DNS resolution point to my server, the specific steps will not be written anymore, if you don’t know how to do it, you can check out my previous blog

insert image description here

This is equivalent to being able to parse, but it is not enough, we need to go back to the 2003 server, open the IIS software to do what we should do most, right-click login , and click [ Properties ] in the drop-down list

insert image description here

Here change the port number to 80 , and then click [ Advanced ]

insert image description here

Select 10.1.1.2 , and then click [ Edit ]

insert image description here

Write the host header value www.login.com , click [ OK ], click three times in total, and the setting is successful. The meaning of the host header value is: when a request arrives at the server side, it is not enough to just look at the IP and port number, but also to check whether the host header value you entered in the address bar of the browser, if the value is This value, I think the binding combination is valid, you are visiting the login website

insert image description here

Go back to xiaoshiyi 's website property settings in the same way as above , and set xiaoshiyi 's host header value to www.xiaoshiyi.com . After setting, refresh the two websites respectively

insert image description here

After refreshing, it is found that the two websites have not stopped, and they use the same IP and port number , which proves that we have successfully set up. Afterwards, when users visit these two websites, they need to use the domain name to access, because the IP and port number of the two websites The port number is the same, only the domain name is different

insert image description here

Finally, go back to the XP client and verify again, open the browser, enter the domain name www.login.com , and press Enter

insert image description here

Enter www.xiaoshiyi.com and press Enter

insert image description here

At this momentWe can publish more websites, as long as we bind different domain names. In fact, the step of binding the host header does not need to be added later. It can be bound when starting to create the website. The steps are as follows

  1. Enter the IIS software, right-click [ Website ], click [ New ] in the drop-down list , and click [ Website ]

insert image description here

  1. Click [ Next ]

insert image description here

  1. Just write your name and click [ Next ]

insert image description here

  1. Here you can see the binding host header , that isBind domain name, just enter

insert image description here

One more thing to add, if our website is bound to the host header , which is the domain name , under normal circumstances, it will fail to enter the IP to access. We can go to the XP client, open the browser, and then enter the IP 10.1.1.2 , enter to see

insert image description here

Some friends may wonder: Is it because the two websites are bound to the same IP address, so direct access by IP will not succeed, or you can stop one of the websites and then use IP to access. We can also try this method. Of course, the result is still not working. Go back to the 2003 server and stop the login .

insert image description here

Now there is only one site left open, let’s go back to XP and open the browser, enter the IP 10.1.1.2 , and press Enter to see

insert image description here

It still doesn’t work, because we have already set the host header value , that is, just input the IP, and the default port. It still doesn’t work, and the server can’t verify whether the binding is valid.Host header value must be revalidated. If we have set the host header value, we want to be able to access it not only through the domain name, but also through IP, what should we do? In fact, there is also a way, the steps are as follows:

  1. Take the xiaoshiyi website as an example, right-click the website, and click [ Properties ]

insert image description here

  1. Click [ Advanced ]

insert image description here

  1. Click【Add

insert image description here

  1. Select 10.1.1.2 for the IP address , fill in 80 for the port number , and click [ OK ]

insert image description here

  1. In fact, the meaning of this setting is: tell the client that there are two ways to access me, one isAccess by domain name, one isDirect access via IP, both ways can access my website, then click [ OK ], click [ OK ]

insert image description here

  1. Go back to the XP client to verify, open the browser and enter the IP 10.1.1.2 , press Enter to see, the access is successful

insert image description here

  1. Then enter the domain name www.xiaoshiyi.com , press Enter to see, it is also a successful visit

insert image description here

In fact, when it comes to this, some friends also thought of it. Since there are multiple ways to access the website, in addition to domain name and IP access, you can alsoSet an alias for the website. If you are interested in these, you can experiment by yourself later, and the explanation of WEB server configuration is all over.

Guess you like

Origin blog.csdn.net/2201_75641637/article/details/132473692