Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Possible Duplicate:
Setting up httpd-vhosts.conf for multiple virtual hosts

Say I have dedicated ip I have all of the dns setup properly for two domains www.a.com and www.b.com

In my apache directory I have /var/www/a/ /var/www/b/

How do I setup the apache vhosts.conf file so that The ip ( goes to /var/www/, A.com goes to /var/www/a, B.com goes to /var/www/b ?

share|improve this question

marked as duplicate by splattne Dec 14 '11 at 6:53

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

gonna have to flag this questiona as it's been answered many times on SF already mate –  iainlbc Dec 14 '11 at 4:59

1 Answer 1

up vote 1 down vote accepted

Use Name based virtual hosts

NameVirtualHost *:80

<VirtualHost *:80>
ServerName a.com
ServerAlias www.a.com
DocumentRoot /var/www/a

<VirtualHost *:80>
ServerName b.com
ServerName www.b.com
DocumentRoot /var/www/b


Depending on your distro the virtual hosts go in /etc/apache2/sites-enabled/ or just the bottom of /etc/httpd/conf/httpd.conf.

The slicehost articles are great for starting out with linux sysadmin/apache/etc.

share|improve this answer
Really appreciate the help. Was wondering how I might get the ip to go to the root directory? –  tester Dec 14 '11 at 6:01

Not the answer you're looking for? Browse other questions tagged or ask your own question.