In web development, it is often necessary to visit a site in the local environment, such as http://localhost or 127.0.0.1. However, if there are more local sites, you have to do something else, such as port settings. The results are not easy to remember.
I use the local Ubuntu+nginx environment, Nginx allows to set up multiple domain names, only need to point to a different storage location. So, how do you set up a domain name of your choice, and this domain only accesses a local site?
In Windows, there is a file: System32/drivers/etc/host, in this file, you can configure the domain name to point to the local IP, for this purpose.
In Ubuntu (this is the case with Linux), the Hosts file is found under/etc, which is equivalent to the same host file. If not, create a new one yourself.
sudo vi/etc/hosts
Add the items you want, in the following format:
<IP> <HOSTNAME>.<DOMAIN> <ALIAS>
Here are some of the configurations I've made:
127.0.0.1 www.v.com #在我的计算机浏览器中输入www. v.com domain name, you can access my locally designated website. Local only, of course. Do not know the insider thought I registered www.v.com this domain name.
127.0.0.1 www.b2b.com
127.0.0.1 www.itdiffer.org
127.0.0.1 www.weixin.com
It should be noted that nginx, in order to do a good conf configuration, so that these domain names have access to the object.
Configure local host to implement local domain name resolution settings