LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 05-10-2010, 01:26 AM   #1
tkmsr
Member
 
Registered: Oct 2006
Distribution: Ubuntu,Open Suse,Debian,Mac OS X
Posts: 798

Rep: Reputation: 39
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.

Now on Lan if I do

http://192.168.1.5
I get abc.com
and if I do
http://192.168.1.5/abc
or http://192.168.1.5/site1


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

following are vhosts in sites-enabled

for abc
Code:
  NameVirtualHost *:80
   <VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName abc.com
        ServerAlias www.abc.com
        DocumentRoot /var/www/abc
        <Directory /var/www/abc >
                Options FollowSymLinks
                AllowOverride None
        </Directory>
  
</VirtualHost>
~
and for site1.abc.com a separate file in /etc/apache2/sites-enabled

Code:
  NameVirtualHost *:80
   <VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName site1.abc.com
        ServerAlias site1.abc.com
        DocumentRoot /var/www/site1
        <Directory /var/www/site1 >
                Options FollowSymLinks
                AllowOverride None
        </Directory>
  
</VirtualHost>
~
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

Last edited by tkmsr; 05-10-2010 at 01:28 AM.
 
Old 05-10-2010, 01:51 AM   #2
John VV
Guru
 
Registered: Aug 2005
Posts: 13,243

Rep: Reputation: 1774Reputation: 1774Reputation: 1774Reputation: 1774Reputation: 1774Reputation: 1774Reputation: 1774Reputation: 1774Reputation: 1774Reputation: 1774Reputation: 1774
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

Last edited by John VV; 05-10-2010 at 01:53 AM.
 
Old 05-10-2010, 03:37 AM   #3
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,957

Rep: Reputation: 1341Reputation: 1341Reputation: 1341Reputation: 1341Reputation: 1341Reputation: 1341Reputation: 1341Reputation: 1341Reputation: 1341Reputation: 1341
Hi,

If you get the message you used to title your thread, then it looks like you don't have enabled vhosts.
What gives:
Code:
httpd -S
 
Old 05-10-2010, 03:43 AM   #4
tkmsr
Member
 
Registered: Oct 2006
Distribution: Ubuntu,Open Suse,Debian,Mac OS X
Posts: 798

Original Poster
Rep: Reputation: 39
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 View Post
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

Last edited by tkmsr; 05-10-2010 at 05:20 AM.
 
Old 05-10-2010, 03:56 AM   #5
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,957

Rep: Reputation: 1341Reputation: 1341Reputation: 1341Reputation: 1341Reputation: 1341Reputation: 1341Reputation: 1341Reputation: 1341Reputation: 1341Reputation: 1341
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.

Regards
 
Old 05-10-2010, 05:02 AM   #6
tkmsr
Member
 
Registered: Oct 2006
Distribution: Ubuntu,Open Suse,Debian,Mac OS X
Posts: 798

Original Poster
Rep: Reputation: 39
Quote:
Originally Posted by bathory View Post
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.

http://httpd.apache.org/docs/2.2/vhosts/examples.html it says

Code:
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.

Or I was accessing the sites on LAN in a wrong way I mean I should have done some thing like
http://192.168.1.5/abc.com
and http://192.168.1.5/site1.abc.com

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.

Last edited by tkmsr; 05-10-2010 at 05:19 AM.
 
Old 05-10-2010, 05:30 AM   #7
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,957

Rep: Reputation: 1341Reputation: 1341Reputation: 1341Reputation: 1341Reputation: 1341Reputation: 1341Reputation: 1341Reputation: 1341Reputation: 1341Reputation: 1341
Quote:
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.

Regards
 
Old 05-10-2010, 05:32 AM   #8
tkmsr
Member
 
Registered: Oct 2006
Distribution: Ubuntu,Open Suse,Debian,Mac OS X
Posts: 798

Original Poster
Rep: Reputation: 39
Quote:
Originally Posted by bathory View Post
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.

Regards
Ok.
 
Old 06-21-2010, 06:10 AM   #9
jimwarr
LQ Newbie
 
Registered: Jun 2010
Distribution: Ubuntu
Posts: 1

Rep: Reputation: 0
The best resource I found for Virtual Host

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.
 
Old 06-21-2010, 11:27 AM   #10
tkmsr
Member
 
Registered: Oct 2006
Distribution: Ubuntu,Open Suse,Debian,Mac OS X
Posts: 798

Original Poster
Rep: Reputation: 39
Fat fingering in ports.conf can you explain a bit what is that you are referring to and I guess this is the link you are referring to.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How does apache2 virtual hosting work? SimbaSpirit Linux - Software 1 06-08-2008 10:05 PM
Virtual hosts on apache2 70mas Linux - Server 3 07-16-2007 03:29 AM
Virtual hosting not point to different sites techneck Linux - Newbie 1 02-21-2006 02:46 PM
hosting multiple sites w/ apache pH* Linux - Networking 2 10-15-2004 04:02 PM
apache2 virtual hosts viniosity Linux - Software 4 02-07-2004 01:15 AM


All times are GMT -5. The time now is 04:51 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration