Friday, April 16, 2010

Virtual Host in Ubuntu linux

My Ubuntu version:

cat /proc/version
Linux version 2.6.31-14-generic (buildd@rothera) (gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu8) ) #48-Ubuntu SMP Fri Oct 16 14:04:26 UTC 2009

/etc/init.d/apache2 restart
* Restarting web server apache2 [Fri Apr 16 1:29:16 2010] [warn] VirtualHost 127.0.0.1:80 overlaps with VirtualHost 127.0.0.1:80, the first has precedence, perhaps you need a NameVirtualHost directive
... waiting [Fri Apr 16 01:29:17 2010] [warn] VirtualHost 127.0.0.1:80 overlaps with VirtualHost 127.0.0.1:80, the first has precedence, perhaps you need a NameVirtualHost directive

if you face the above error.

That means while setting the vhosts we create a simple file like zoo.com in /etc/apache2/sites-available

content in zoo.com file will be
<>
ServerName zoo.com
ServerAdmin "info@tasmeemme.com"
DocumentRoot /var/www/vhosts/zoo
CustomLog /var/www/vhosts/logs/access_log plesklog
ErrorLog /var/www/vhosts/statistics/logs/error_log
<
>

then create a soft link to that file in /etc/apache2/sites-enabled with same name as zoo.com

restart apache.
Now I guess everything works fine.
But the problem comes once you add one more file with the same iP and port.
Example create ram.com with same content as zoo.com
then restart apache you will get the below error

VirtualHost 127.0.0.1:80 overlaps with VirtualHost 127.0.0.1:80,

So both are lisetening at the same ip address,That is the issue to resolve this.

add differnt ip address to sites.
example
127.0.0.1 localhost
127.0.0.9 ram.com
127.0.0.10 kavali.com
127.0.0.13 zoo.com
something like this in /etc/hosts file

Ping above sites .. you will get reply with out network or may be very fast response that means it's correct.
Change the zoo.com file in
/etc/apache2/sites-available with change ip address.
with the ip you entered in hosts file.
Restart apache ..This time you won't get any error.

Thanks
Murthy Kavali

No comments: