Configure local host to implement local domain name resolution settings

Source: Internet
Author: User

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

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.