Many friends want to build their computers as servers so that others can access them. For example, if you write a website on your own, you can only access it through localhost or 127.0.0.1. But how can we make other people's computers accessible? Let's take a look at your own website. Now let's talk about how to allow hosts in the LAN to access your host.
First, we need to install Apache. Everyone knows this! Apache is a well-recognized web server software in the world. Download Apache and install it. The installation process is silly and easy. Start the service, and enter 127.0.0.1 in the browser. If you can see a default webpage, it indicates that Apache has been installed successfully. We should know that 127.0.0.1 is the local loopback address! That is to say, It accesses the local machine and is designed for testing by developers. Let's first explain the differences between 127.0.0.1 and localhost. For example, Baidu server has an IP address 115.239.210.27. You can access it through the IP address of Baidu (enter http: // 115.239.210.27/in a browser, note the IP address is too hard to remember, we will enter the http://www.baidu.com in the address bar of the browser to enter, www.baidu.com is Baidu's domain name, similarly, our local localhost is like 127.0.0.1 domain name, therefore, the input localhost is the same as the input 127.0.0.1. In fact, we can completely modify our domain name, in the hosts file under Window System C: \ windows \ system32 \ drivers \ etc, open the last line in notepad and you will see that it is useless # comment on the line 127.0.0.1 localhost. This sentence means that the domain name corresponding to 127.0.0.1 is localhost .. Therefore, you can modify your own domain name, but it is strongly recommended that you do not modify this because localhost is already recognized worldwide and cannot be accessed if you modify it. What is the role of hosts? When a user enters a URL in the browser to log on to, the system will first automatically find the corresponding IP address from the hosts file. Once found, the system will immediately open the corresponding webpage. If not found, the system then submits the website address to the DNS server for IP Address Resolution. If you add 127.0.0.1 www.baidu.com to the last line in the hosts file, you will not be able to access the port every time you log on to Baidu and go to 127.0.0.1. Hey, is it fun? So that you can get some hands and feet on someone else's computer to get some prank. It seems to be too far away.
Now that the Apache server is set up, start it. Now 127.0.0.1 or localhost can be accessed. What should I do if I use the IP address of my host? Enter ipconfig in your cmd to check your IP address, for example, 192.168.1.104, and enter 192.168.1.104 in your browser. An error occurs. This is a matter of course, so you need to configure Apache. Open the Apache configuration file httpd. conf. Find the file in the Apache installation file and find the content.
# Onlineoffline tag-don't remove order deny, allow deny from all allow from 127.0.0.1, deny from all: deny all access requests. Allow from 127.0.0.1 allows access requests from 127.0.0.1.
Add # Before deny from all to comment out this line, and add a line of allow from 192.168.1. * after allow from 127.0.0.1. The modification is as follows: # onlineoffline tag-don't remove order deny, allow # deny from all allow from 127.0.0.1 allow from 192.168.1. * When this line is added, all hosts in the network segment 192.168.1 can access their own servers. After configuration, enter your url in your browser or enter your url in your roommate's Computer Browser. If you can see a successful web page by default
Configure Apache to make your computer a server so that computers in the LAN can access your host.