NameVirtualHost *:80 has no virtual hosts apache2 hosting multiple sites without DNS
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
NameVirtualHost *:80 has no virtual hosts apache2 hosting multiple sites without DNS
Hi,
I have some problem in apache2 configuration.
I have two websites on same IP on LAN.i.e. 192.168.1.5
site1.abc.com
and abc.com
both have different document roots
for abc.com document root
/var/www/abc
and for site1.abc.com document root
/var/www/site1
the above sites are on a server which is accessible to me only via SSH.
then in both cases I am getting abc.com which is alphabetically first vhost (that is also how apache2 serves)
What should I do to be able to access both the websites
What should I check in a few blogs I checked they said to mention in /etc/apache2/apache2.conf
ServerName.
But in this case what should I put I have two different websites or what other thing I have missed?
I am using Debian Lenny and apache2
it has been a while but. http://httpd.apache.org/docs/2.2/vhosts/examples.html
you do not need the *:80 port in there
or you can set one to 80 and the other to 8080
"Running different sites on different ports."
but i use this
"Using the ServerPath directive"
and no-ip.com
Unfortunately even before I could reply my system has crashed.So now I have even more problem but please let me know what you wanted to know from httpd -S and what according to you could have been possible reason of error.
Quote:
Originally Posted by John VV
it has been a while but. http://httpd.apache.org/docs/2.2/vhosts/examples.html
you do not need the *:80 port in there
or you can set one to 80 and the other to 8080
"Running different sites on different ports."
but i use this
"Using the ServerPath directive"
and no-ip.com
John I had looked that link before you posted and had try to do the same you said and it had failed.So I posted the question any more clues.If you were to do as above of mine on different port then how would you give ServerPath I had read that but could not understand how to use it.
is it some thing like
ServerPath <Document Root of site>
in the link you say my doubt is I have two files in site-enabled directory should I keep ServerPath in both vhost files
site1.abc.com and abc.com
httpd -S should show you the vhosts that are running by your apache server
The error means that apache expects to find some vhosts, on port 80, but there are no vhosts defined.
I don't use Debian, but I know it uses a2ensite to create symlinks to the vhosts' definition files, so maybe those symlinks do not exist.
the vhosts' definition files, so maybe those symlinks do not exist.
Regards
Before it crashed the symlinks do existed.The vhost definition had some problem since when ever I restarted Apache it gave me error NameVirtualHost does not exist.
Inspite of the fact that there were separate vhost files for site1.abc.com and abc.com in sites-enabled directory.
In order to match the correct virtual host a client must send the correct
Host: header. Old HTTP/1.0 clients do not send such a header and Apache has
no clue what vhost the client tried to reach (and serves the request
from the primary vhost)
That is what was exactly happening.If I typed in browser http://192.168.1.5 I get abc.com which alphabetically was coming first.
Before it crashed I used a Firefox plugin Live HTTP headers
to see which header was going to webserver and it came to be HTTP 1.0 to which the above links says is a problem.I was surprised since I am using mozilla 3.6.3 if this has a problem then which brower sends correct HTTP :host header.
If ServerPath is to be used how is this to be used in my case ?
What I am not clear is /etc/apache2/sites-enabled/abc.com
/etc/apache2/sites-enabled/site1.abc.com
in both the files I should use ServerName or I should create a separate default file for this.
That is what was exactly happening.If I typed in browser http://192.168.1.5 I get abc.com which alphabetically was coming first.
This is absolutely normal. Using an IP address is not the same as a vhost, so apache serves the 1st vhost.
Don't be confused with HTTP/1.0 headers and things like that. Since you get the " NameVirtualHost *:80 has no virtual hosts..." error, vhosts are not going to work.
When your box is up again, use the httpd -S to see if you have any hosts defined (I guess you don't) and maybe post the configs here for more help.
This is absolutely normal. Using an IP address is not the same as a vhost, so apache serves the 1st vhost.
Don't be confused with HTTP/1.0 headers and things like that. Since you get the " NameVirtualHost *:80 has no virtual hosts..." error, vhosts are not going to work.
When your box is up again, use the httpd -S to see if you have any hosts defined (I guess you don't) and maybe post the configs here for more help.
I was having similar issues. Followed the instructions here and it worked like a charm, at library.linode.com/web-servers/apache/installation/ubuntu-10.04-lucid#configure_apache_for_named_based_virtual_hosting.
(This is my first post and I cannot do links.)
My issue was fat fingering in ports.conf. Once resolved, I removed and recreated the sites and life is good.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.