LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How do I test my vhost before setting DNS? (https://www.linuxquestions.org/questions/linux-newbie-8/how-do-i-test-my-vhost-before-setting-dns-407003/)

sjenkinsdc 01-23-2006 12:13 PM

How do I test my vhost before setting DNS?
 
I'm moving a site to my new dedicated server. I have name-based vhosts set up. However, before I set the URL to point to my new server, I'd like to test my setup on the dedicated server.

How can I do this? I've searched a few threads and cannot find an answer. I'd like to access the site to test it before making it live. If I point the URL to the new server and it is no good, then that no-good!!!

I've got a LAMP setup going on.

Thanks for any help anyone can provide this somewhat informed newbie.

marozsas 01-23-2006 12:33 PM

You need to set up your own name<->ip translation to the new ip, overriding the current one.

Let say your URL site is www.whatever.com which binds to 123.123.123.123 on internet.

Let say your new server would be 231.231.231.231.

In a linux machine put a line in your /etc/hosts file to point to this new ip:

231.231.231.231 www.whatever.com

(you may to restart the nscd daemon. Also, in the file /etc/nsswitch.conf, the line "hosts: files dns" must have "files" first).
After changing /etc/hosts, ping www.whatever.com would return results from 231.231.231.231.

In a windows machine the equivalent file is \Windows\System32\drivers\etc\hosts


regards,

sjenkinsdc 01-23-2006 01:21 PM

So I don't need to do anything on the server, just update the hosts file on my client machine?

Is there anyway to directly access the vhost using the IP address? For example, I know you can access users accounts by ipaddress slash ~username. Any similar way to do this to access vhost?

marozsas 01-24-2006 04:20 AM

Quote:

Originally Posted by sjenkinsdc
So I don't need to do anything on the server, just update the hosts file on my client machine?

Yes. That's right. You just need the test machine be able to translate the server name to the new ip address. You need to "by-pass" the standard conversion process, because it would return the original ip address.

Quote:

Originally Posted by sjenkinsdc
Is there anyway to directly access the vhost using the IP address? For example, I know you can access users accounts by ipaddress slash ~username. Any similar way to do this to access vhost?

No, because you told me the server is "name based", not "ip based". When your browser contact the web server at the new ip, the request includes the name of the server. This name in the request is used by the web server to decide which virtual site would reply.

request,

sjenkinsdc 01-27-2006 05:13 PM

Thank you for your help
 
A big thanks for quickly and succinctly answering my question. Much appreciated.


All times are GMT -5. The time now is 04:28 AM.