Fedora Linux Support Community & Resources Center
  #1  
Old 9th October 2009, 07:47 PM
Gerr1t Offline
Registered User
 
Join Date: Oct 2009
Posts: 7
windows_xp_2003ie
Apache problem

Hey Guys,

I'm having a little problem with the config of apache.

For a school project I need to host 2 websites with apache.

My DNS is ready to go, I tested it and it works perfectly.

Below are the settings in my httpd.conf wich is giving me some problems:
Code:
NameVirtualHost 10.1.11.20:80

#
#
#

<VirtualHost 10.1.11.20:80>
	DocumentRoot "/var/www/html"
</VirtualHost>
<VirtualHost server.Domain1.local:80>
	DocumentRoot "/var/www/html/domain1/"
	ServerName server.Domain1.local
</VirtualHost>
<VirtualHost server.Domain2.intra:80>
	DocumentRoot "/var/www/html/domain2/"
	ServerName server.Domain2.intra:80
</VirtualHost>
My server is 10.1.11.20.
The problem is when I login to my windows XP workstation and go to www.Domain1.local (www is CNAMED correctly in DNS and tested) I dont get forwarded to /html/domain1, but I get forwarded to /html/, where I can see the 2 directory's domain1 and domain2. I can open them both and then I get forwarded to the index pages wich are included in the directory's.

Is there something wrong with the settings listed above?
I dont get it! :P

Thanks in advance!
Reply With Quote
  #2  
Old 9th October 2009, 10:38 PM
fissy Offline
Registered User
 
Join Date: Oct 2006
Age: 29
Posts: 4
macosfirefox
Are you sure your virtual host declarations should have server names in them? That is what the ServerName directive is for.

Try this:
Code:
NameVirtualHost *:80

#
#
#

<VirtualHost *:80>
	DocumentRoot "/var/www/html"
</VirtualHost>
<VirtualHost *:80>
	DocumentRoot "/var/www/html/domain1/"
	ServerName server.Domain1.local
</VirtualHost>
<VirtualHost *:80>
	DocumentRoot "/var/www/html/domain2/"
	ServerName server.Domain2.intra
</VirtualHost>
If it is important the sites work only on that IP (i.e. you have multiple IPs) replace the asterisks (*) with your IP address. Bear in mind that if the browser accesses your server by IP address they will still go to the first virtual host (DocumentRoot "/var/www/html")

fissy
Reply With Quote
  #3  
Old 10th October 2009, 02:09 PM
Gerr1t Offline
Registered User
 
Join Date: Oct 2009
Posts: 7
windows_vistaie
Hey Fissy,

Thanks for the tip..

I tried the following things..

First I deleted the first VirtualHost entry, cause linking my IP to the /html directory isnt needed, DNS links the names to the correct ip.

I changed my httpd.conf to:
Code:
NameVirtualHost 10.1.11.20:80

#
#
#

</VirtualHost>
<VirtualHost server.Domain1.local:80>
	DocumentRoot "/var/www/html/domain1/"
	ServerName server.Domain1.local
</VirtualHost>
<VirtualHost server.Domain2.intra:80>
	DocumentRoot "/var/www/html/domain2/"
	ServerName server.Domain2.intra:80
</VirtualHost>
This had an effect. I tested on my workstation and types in www.Domain1.local.. I got directed to html/domain1/... great!
Then I tested www.Domain2.intra, he directed me too html/domain1/ aswell.. failed .

So I tried ur tip, removing the server names and changed the file to this:

Code:
NameVirtualHost *:80

#
#
#

</VirtualHost>
<VirtualHost *:80>
	DocumentRoot "/var/www/html/domain1/"
	ServerName server.Domain1.local
</VirtualHost>
<VirtualHost *:80>
	DocumentRoot "/var/www/html/domain2/"
	ServerName server.Domain2.intra
</VirtualHost>
This had no effect, after restarting httpd, both the links still show /domain1/.

It kinda makes sence to me.. When typing in www.Domain1.local, DNS gives back the IP adress 10.1.11.20:80. Httpd then takes the first VirtualHost that matches the Servername and gives that DocumentRoot.
The problem is, both server.Domain1.local and server.Domain2.intra are linked to the same IP adress (his own, the server).

Could that be the problem?

If it is, how is it fixable? I mean, hosting multiple websites on one server should not be a problem at all!

Thanks in advance guys!
Reply With Quote
  #4  
Old 10th October 2009, 04:52 PM
Undy Offline
Registered User
 
Join Date: May 2009
Posts: 32
macossafari
Does your ServerName directive actually say www or server? It should match exactly what is being typed in the browser. I would lose any uppercase letters too.

<VirtualHost *:80>
DocumentRoot "/var/www/html/domain1/"
ServerName www.domain1.local
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/var/www/html/domain2/"
ServerName www.domain2.intra
</VirtualHost>

Also, tail your log and error files, see if there is something in there to give you a clue. Check this link http://httpd.apache.org/docs/1.3/vhosts/name-based.html
Reply With Quote
  #5  
Old 24th October 2009, 06:35 AM
marcrblevins's Avatar
marcrblevins Offline
Registered User
 
Join Date: Jun 2006
Location: Texas
Age: 42
Posts: 4,168
linuxfedorafirefox
No quotes around the DocumentRoot lines?

Here is my version, working of course:
Code:
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
#
# NOTE: NameVirtualHost cannot be used without a port specifier
# (e.g. :80) if mod_ssl is being used, due to the nature of the
# SSL protocol.
#

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
#<VirtualHost *:80>
#    ServerAdmin webmaster@dummy-host.example.com
#    DocumentRoot /www/docs/dummy-host.example.com
#    ServerName dummy-host.example.com
#    ErrorLog logs/dummy-host.example.com-error_log
#    CustomLog logs/dummy-host.example.com-access_log common
#</VirtualHost>
<VirtualHost *:80>
    DocumentRoot /home/marc/Public
    ServerName kiriyamablevins.dyndns.org
</VirtualHost>
<VirtualHost *:80>
    DocumentRoot /usr/share/wordpress
    ServerName kiriyamablevins.blogsite.org
</VirtualHost>
<VirtualHost *:80>
    DocumentRoot /home/marc/Public/marc
    ServerName marcrblevins.dyndns.org
</VirtualHost>
Reply With Quote
Reply

Tags
apache, problem

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in apache again shreedhan Servers & Networking 3 31st July 2007 09:17 AM
Problem in apache+ssl sixth.neo Servers & Networking 5 5th December 2006 09:09 AM
problem with apache lin Servers & Networking 1 23rd May 2006 04:11 AM
Problem not sure if it is Apache or DNS! psycobass Servers & Networking 3 26th May 2005 10:49 PM
SSH/Apache Problem Jburrell Servers & Networking 2 22nd October 2004 01:48 AM


Current GMT-time: 11:41 (Saturday, 25-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat