Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot /var/www/html/www.mbas.co.in
    ServerName mbas.co.in
    ErrorLog logs/mbas.co.in-error_log
    CustomLog logs/mbas.co.in-access_log common
</VirtualHost>
<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot /var/www/html/onlinemba123
    ServerName onlinemba123
    ErrorLog logs/onlinemba123-error_log
    CustomLog logs/onlinemba123-access_log common
</VirtualHost>
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

2 Answers 2

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 127.0.0.1 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] old_site.co.in. 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 http://new_site.co.in, 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 (old_site.co.in and new_site.co.in) 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/www.old_site.co.in when a browser tries to open http://www.old_site.co.in and the contents of /html/www.new_site.co.in if the browser asks for http://www.new_site.co.in. 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 new_site.com, 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 new_site.co.in to see if your DNS entry is correct. –  Sven Feb 9 '11 at 12:24

Your Answer

 
discard

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.