Click to See Complete Forum and Search --> : Virtual Hosting on Apache


qweqwe1
01-28-2003, 05:06 AM
i know this a very common topic here ..i did searched in this forum and also on google ..some how i am unable to make this work...

i hv a RH 6.2 and Apache 1.3.9 box. i hv registered two domains domain1.com and domain2.com. both pointing to my static IP address. now i want to set up virtual hosts ..i mean when anyone types www.domain1.com it shd take them to /home/httpd/html and for www.domain2.com to www/docs/www.domain2.com.

i checked the VirtualHost docs ..its said i need to modify my http.conf as follows ..

<VirtualHost www.domain1.com>
ServerAdmin root@.domain1.com
DocumentRoot /home/httpd/html/virtual/linux
ServerName www.domain1.com
ErrorLog logs/linux-error_log
TransferLog logs/linux-access_log
</VirtualHost>


accordingly i modified my http.conf file ..


<VirtualHost www.ojoobala.com>
ServerAdmin root@localhost
DocumentRoot /home/httpd/html
ServerName www.ojoobala.com
ErrorLog logs/www.ojoobala.com-error_log
TransferLog logs/www.ojoobala.com-access_log
</VirtualHost>


<VirtualHost www.ashhirwaadassociates.com>
ServerAdmin root@localhost
DocumentRoot /www/docs/www.ashhirwaadassociates.com
ServerName www.ashhirwaadassociates.com
ErrorLog logs/www.ashhirwaadassociates.com-error_log
TransferLog logs/www.ashhirwaadassociates.com-access_log
</VirtualHost>

serversignature off
servertokens full


when i restarted httpd ..i got error VirtualHost www.ojoobala.com overlaps VirtualHost www.ashhirwaadassociates.com perhaps u need a NamedVirtualHost Directive.


i searched again ..then one of post mentioned to use the IP address so i modified my httpd.conf as follows


<VirtualHost my.ip.add.ress>
ServerAdmin root@localhost
DocumentRoot /home/httpd/html
ServerName www.ojoobala.com
ErrorLog logs/www.ojoobala.com-error_log
TransferLog logs/www.ojoobala.com-access_log
</VirtualHost>


<VirtualHost my.ip.add.ress>
ServerAdmin root@localhost
DocumentRoot /www/docs/www.ashhirwaadassociates.com
ServerName www.ashhirwaadassociates.com
ErrorLog logs/www.ashhirwaadassociates.com-error_log
TransferLog logs/www.ashhirwaadassociates.com-access_log
</VirtualHost>

once again when i restarted httpd i got the same overlap error but this time with ip address.

when i access the website with www.ojoobala.com i am getting the www.ashhirwaadassociates.com default page.

i dont know what i am doing wrong ...i appreciate ur help ..thanks a lot...

-qweqwe

qweqwe1
01-28-2003, 05:36 AM
figured it out ..found this posting ..and it worked :-)

vi /etc/httpd/conf/httpd.conf
NameVirtualHost 206.239.34.148

<VirtualHost 206.239.34.148>
ServerName pryzby.mnsinc.com
ServerAdmin gjp@valinux.com
DocumentRoot /home/httpd/html
ErrorLog logs/pryzby.mnsinc.com-error_log
TransferLog logs/pryzby.mnsinc.com-access_log
</VirtualHost>

<VirtualHost 206.239.34.148>
ServerName www.pryzby.org
ServerAdmin gjp@valinux.com
DocumentRoot /home/httpd/pryzby
ErrorLog logs/pryzby.org-error_log
TransferLog logs/pryzby.org-access_log
</VirtualHost>

<VirtualHost 206.239.34.148>
ServerName www.whatsgnu.org
ServerAdmin gjp@valinux.com
DocumentRoot /home/httpd/whatsgnu
ErrorLog logs/whatsgnu.org-error_log
TransferLog logs/whatsgnu.org-access_log
</VirtualHost>

index.html in
/home/httpd/html
/home/httpd/pryzby
/home/httpd/whatsgnu

/etc/rc.d/init.d/httpd restart

vbp6us
01-29-2003, 02:05 AM
I know you got it done and good job but heres my way...
Heres my setup if that helps you:

NameVirtualHost 192.168.1.102

<VirtualHost 192.168.1.102>
ServerName www.asappainting.com
DocumentRoot /srv/www/htdocs/asappainting/
ServerAlias asappainting.com
DirectoryIndex index.php index.html index.htm index.shtml
</VirtualHost>

<VirtualHost 192.168.1.102>
ServerName www.theclothingline.com
DocumentRoot /srv/www/htdocs/wyd/
ServerAlias theclothingline.com
DirectoryIndex index.php index.html index.htm index.shtml
</VirtualHost>