Jump to content

[SOLVED] BIND and Apache Virtual Host


etrader

Recommended Posts

I have two domain on my server. I configured BIND DNS and two virtual host on apache server for them.

 

The first domain works well, but when browsing the second domain, it shows the content of first apache virtual host, instead of the second one with the name of the second domain.  :(

It's a long file on /etc/httpd/conf

 

I think you mean the last part, which is

 

<VirtualHost 200.35.149.48>

DocumentRoot "/var/www/html/site1"

<Directory "/var/www/html/site1">

allow from all

Options +Indexes

</Directory>

</VirtualHost>

<VirtualHost 200.35.149.48>

DocumentRoot "/var/www/html/site2"

<Directory "/var/www/html/site2">

allow from all

Options +Indexes

</Directory>

</VirtualHost>

You need to be using name based virtual hosts.

 

 

 

Basic example:

 

 

NameVirtualHost *:80

<VirtualHost *:80>

ServerName domain1.tld

DocumentRoot "/path/to/doc/root/"

</VirtualHost>

 

<VirtualHost *:80>

ServerName domain2.tld

DocumentRoot "/path/to/doc/root2/"

</VirtualHost>

The only possible lag you may have felt would be the domain name resolving, which shouldn't be noticeable, and Apache handling the virtual host, which should definitely not be noticeable.

 

 

In other words, it was probably in your head ;p.

Sorry for this, but the problem still persists :(

 

The httpd.conf now looks like

 

<VirtualHost *:80>

DocumentRoot /var/www/html/site1

<Directory "/var/www/html/site1">

allow from all

Options +Indexes

</Directory>

ServerName www.site1.com

</VirtualHost>

<VirtualHost *:80>

DocumentRoot /var/www/html/site2

<Directory "/var/www/html/site2">

allow from all

Options +Indexes

</Directory>

ServerName www.site2.com

</VirtualHost>

  • 3 weeks later...

You have

 

NameVirtualHost *:80

 

Somewhere, yes?

 

 

 

Also, I don't think the <Directory> tags should be inside the <VirtualHost> tags.

 

You were quite write, corbin

 

The problem was related to "NameVirtualHost *:80"

 

Thanks a million :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.