Windows
1. Open Notepad or any other Text editor of your choice from Start Menu with Administrator Priveledges.
Note – Without administrator priveledges, one cannot save the hosts file changes done in the editor.
2. Now open the file the following file:
C:\Windows\System32\Drivers\etc\hosts
3. Amend the file with IP Address followed by space and domain/hostname.
4. Save file and close Text Editor.
5. Open Command prompt from Start Menu and type
ping domain.tld
domain.tld here is domain/hostname for which you wanted to set up the virtual host.
6. The output should show the IP you added in ‘C:\Windows\System32\Drivers\etc\hosts‘
along with domain/hostname. If not then flush the DNS.
Linux and MacOS
1. Open Terminal and run the following command
sudo nano /etc/hosts
2. Enter your user password in the prompt and press enter
3. Amend the file with IP Address followed by space and domain/hostname.
4. Press ctrl+O
to save the file and then press ctrl+x
to exit
5. In terminal type
ping domain.tld
domain.tld
here is domain/hostname for which you wanted to setup virtual host.
6. The output should show the IP you added in ‘etc/hosts’
along with domain/hostname. If not then flush the DNS.