Home  >  Article  >  Backend Development  >  How to set up hosts on Mac computer (steps with pictures and text)

How to set up hosts on Mac computer (steps with pictures and text)

安安杰尼
安安杰尼Original
2020-04-29 22:27:43208221browse

What is the hosts file?

The hosts file is a system file. By binding the relationship between the domain name and the IP, when the machine accesses the domain name, it will find the corresponding file from this file. If the record is found, the corresponding web page will be opened immediately. If not found, DNS public network resolution will be used to open the web page. Therefore, it is a good way to speed up access and local development and bind domain names.

Mac computer sets hosts local virtual domain name access steps:

Step 1: Find the terminal in the mac computer and open it (click on the upper left corner of the desktop [Magnifying glass] to "Search", enter "Term" or "term" and the "Terminal" will be displayed, and then open it.) As shown below :

How to set up hosts on Mac computer (steps with pictures and text)

Step 2: Input sudo vim /ect/hosts in the opened window and press "Enter key" Enter

How to set up hosts on Mac computer (steps with pictures and text)

Step 3:Enter the password set by your MAC computer and press Enter

How to set up hosts on Mac computer (steps with pictures and text)

The following content will be displayed

How to set up hosts on Mac computer (steps with pictures and text)

Step 4: In the input method English mode, enter i to enter the editing mode. This An INSERT will be displayed in the lower left corner. Press the down and right keys on the keyboard to move the cursor to the end of the last line, and then press Enter to start a new line. Enter 127.0.0.1 www.test.com as shown below This domain name can be replaced with your own domain name

How to set up hosts on Mac computer (steps with pictures and text)

Step 5:Then Press the ESC key , then enter :wq and press Enter. It will be automatically saved and you can end the editor.

In this way, the hosts domain name has been added successfully. You can check whether it takes effect by ping www.test.com.

At this point, the Mac computer has set up the hosts file and set up access to the local virtual domain name. This will make it much more convenient for us to develop and demonstrate the local website program. Hurry up and try it!

Note: phpstudy V8 PHP development integrated environment can be added to the local hosts file by default when adding a domain name, but currently only supports the Windows version. We look forward to the early development of the MAC version of phpstudy Finish!

The above is the detailed content of How to set up hosts on Mac computer (steps with pictures and text). For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn