You shouldn't have to make any changes in httpd2.conf to add a virtual host. There is a section in httpd2.conf that includes the vhosts.conf file -- it's set by default, and should look something like this:
Code:
###
### Virtual Hosts
###
# We include different templates for Virtual Hosting. Have a look in the
# vhosts directory and modify to suit your needs.
Include conf/vhosts/Vhosts.conf
#Include conf/vhosts/DynamicVhosts.conf
#Include conf/vhosts/VirtualHomePages.conf
The sites I am hosting are sunshine-market.com and bluewillowherbs.biz. Here's my Vhosts.conf:
Code:
NameVirtualHost 168.103.142.125:80
<VirtualHost 168.103.142.125:80>
ServerName www.sunshine-market.com
DocumentRoot "/var/www/html/www.sunshine-market.com"
TransferLog logs/access_log
ErrorLog logs/error_log
</VirtualHost>
<VirtualHost 168.103.142.125:80>
ServerName www.bluewillowherbs.biz
ServerAlias bluewillowherbs.biz
DocumentRoot "/var/www/html/www.bluewillowherbs.biz"
TransferLog logs/bluewillow-access.log
ErrorLog logs/bluewillow-error.log
</VirtualHost>
The first directive, NameVirtualHost, tells Apache that you're using name based virtual hosting (preferable in most cases). This means that you can add virtual hosts under one IP address. The VirtualHost containers contain the configuration for each vhost. The first one I have refers to sunshine-market.com, which is the default domain on my system -- sunshine-market.com is the one I set up in httpd2.conf initially but as the answer to my first question above pointed out, I had to add a virtual host for it as well. The second container refers to bluewillowherbs.biz.
All I had to do was set up the directives for each vhost, like the server name, doc root, etc, and I just copied the directives from httpd2.conf for my sunshine-market.com vhost.
In your example case, the vhosts file should look a little like this:
Code:
NameVirtualHost your.ip.address:80
<VirtualHost your.ip.address:80>
ServerName domain1
DocumentRoot "/var/www/html/domain1"
TransferLog logs/access_log
ErrorLog logs/error_log
</VirtualHost>
<VirtualHost your.ip.address:80>
ServerName domain2
DocumentRoot "/var/www/html/domain2"
TransferLog logs/domain2-access.log
ErrorLog logs/domain2-error.log
</VirtualHost>
Of course, you can have different log file names and directory structures. Plus, you can add more directives to a certain vhost container to restrict access to certain folders for ex, or give cgi permissions to a folder, etc.
This link,
http://httpd.apache.org/docs-2.0/vhosts/ , is directly from Apache's docs. It explains everything very well.
Good luck!