Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I started virtual host on my VPS,

I am having two websites on it, one which was already there and the second which I trasferred now, But before changing the name-servers of the new transfered wordpress site, I want to test it. How can I check it, whether its working with no errors, or some errors are there?

When I type my IP address of the VPS I get my old website, if I type http://ip/new_site_folder_name I get 404, no such page found

My virtual host config is this:

    NameVirtualHost *:80
    <VirtualHost *:80>
    DocumentRoot /var/www/html/
    ErrorLog logs/
    CustomLog logs/ common
<VirtualHost *:80>
    DocumentRoot /var/www/html/onlinemba123
    ServerName onlinemba123
    ErrorLog logs/onlinemba123-error_log
    CustomLog logs/onlinemba123-access_log common
share|improve this question
If you use the IP addy, you'll always get the first vhost Apache is configured for; your second vhost has an interesting hostname, you're entering http://onlinemba123 into your browser and have that exact hostname mapped in your hosts file? – Chris S Feb 10 '11 at 13:36
@Chris S so in ServerName I have to change from onlinemba123 to onlinemba123 Am I rite? – ntechi Feb 10 '11 at 15:53
ServerName should be exactly what you enter into the address bar after http:// and before /whatever/page.html. – Chris S Feb 10 '11 at 15:57
@Chris S I enter exactly same, but one more thing, do I have to set DNS settings?, cause I haven't till yet – ntechi Feb 10 '11 at 16:05
@Ntechi, you don't have to change DNS. There must be something else in your configuration file that's messing this up. What you have above is syntactically correct. – Chris S Feb 10 '11 at 16:13
up vote 1 down vote accepted

It looks like you've already changed your DNS, which is fine. But I wanted to mention that if you want to test your virtual host configuration before messing with the DNS settings (useful if you want to keep an old site live while you get everything ready on the new host) you can temporarily make the change in your hosts file on your local computer and the change will take effect immediately.

share|improve this answer
in hosts file, what IP should I write or the current VPS IP? – ntechi Feb 9 '11 at 12:50
On the computer your testing from (the workstation you're sitting at) edit the hosts files and put in [ip_of_server] Test (with a browser on your computer). Then remove the line. – Chris S Feb 9 '11 at 13:55
@Chris S, I tried that, when I enter in URL, then my old site is opening, instead of the new one, why so – ntechi Feb 9 '11 at 14:13
Correcting your configuration is outside the scope of the original question. This isn't a forum for ongoing discussions. From the Apache documentation "the argument to VirtualHost must match the argument to NameVirtualHost" – Chris S Feb 9 '11 at 14:20
@Chris S I didn't get you, Is there anything wrong with my virtual host config? – ntechi Feb 9 '11 at 15:43

You have to use the form, the folder name is irrelevant because it will become the root folder of your site.

Edit - Explanation of vhosts

Based on your comments, I don't think you understand how virtual hosts in Apache work.

First, both domains ( and must point to the IP of your machine (this is a DNS thing). With the site definitions your wrote in your post, you will then tell apache to serve the contents of /html/ when a browser tries to open and the contents of /html/ if the browser asks for This works even if both domains have the same IP address because the site name is transferred in the HTTP request.

share|improve this answer
I agree. The ip/new_site_folder_name scheme is not a function of apache. It's frequently part of some control panel software (such as Plesk, or cPanel), but it does not exist on a default apache installation on CentOS. – Joe Feb 9 '11 at 11:48
but my folder name is same as my domain name, which is pointing somewhere, so that website will open, any other way? And if I change the folder name, and then type on url, will it get opened? I think their will be no such site with this name, so it will return 404 – ntechi Feb 9 '11 at 11:50
Why don't you just try it? Also, see my edit for an explanation of how this works. – Sven Feb 9 '11 at 12:02
OK in my DNS, I have added everything, and I also changed the folder name, but now when I type new_named_site, I get server not found – ntechi Feb 9 '11 at 12:12
This might be because DNS entries might take a while before propagating. Try the command nslookup to see if your DNS entry is correct. – Sven Feb 9 '11 at 12:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.