VPS IP address for local site

8,274

Step Six — Set Up Local Hosts File (Optional)

If you haven't been using actual domain names that you own to test this procedure and have been using some example domains instead, you can at least test the functionality of this process by temporarily modifying the hosts file on your local computer.

This will intercept any requests for the domains that you configured and point them to your VPS server, just as the DNS system would do if you were using registered domains. This will only work from your computer though, and is simply useful for testing purposes.

Make sure you are operating on your local computer for these steps and not your VPS server. You will need to know the computer's administrative password or otherwise be a member of the administrative group.

If you are on a Mac or Linux computer, edit your local file with administrative privileges by typing:

sudo nano /etc/hosts

He is clearly talking about a second machine not the VPS server. Because if those domains are not yours, you can't have a public DNS to point them to your VPS server. So you can go the other way and trick your second machine using hosts files.

  1. In your VPS server, run ifconfig to get its public IP.
  2. In you second machine, edit /etc/hosts file and add the below line with that IP:

    vps-server-ip example.com
    vps-server-ip test.com
    
Share:
8,274

Related videos on Youtube

hasanghaforian
Author by

hasanghaforian

Updated on September 18, 2022

Comments

  • hasanghaforian
    hasanghaforian over 1 year

    I have no experience in about Apache and want to set up Apache Virtual Hosts on Ubuntu 14.04 LTS for a local site on my local machine. I followed this page. But when I try to test http://example.com I got this result in browser:

     Example Domain
    
     This domain is established to be used for illustrative examples in
     documents. You may use this domain in examples without prior
     coordination or asking for permission.
    
     More information...
    

    And I expected to get Success! The example.com virtual host is working! as result (as described in followed tutorial).

    In that tutorial, I did not understand:

     For the domains that I used in this guide, assuming that my VPS IP
     address is 111.111.111.111, I could add the following lines to the
     bottom of my hosts file
    

    So I used 111.111.111.111 in /etc/hosts and I guess problem is in about that, but I searched in google and did not find any thing about how to get my VPS IP address to use that. Now how I can get that address or I make mistake and I have to set an address and then use it? In second case how can I do that?

    • Panther
      Panther about 8 years
      You need to change "111.111.111.111" to your actual ip address and "example.com" to your actual server name.
    • hasanghaforian
      hasanghaforian about 8 years
      @bodhi.zazen I think example.com is actual server name. But does changing to actual IP Address cause any problem?