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

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

  • 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 :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.