Regarding Virtual Hosts & Domains
jerrymc at clunix.cl.msu.edu
Mon May 19 07:12:53 PDT 2003
> This e-mail is regarding setting up virtual hosts and hosting more then
> one domain on my freebsd machine. I currently registered two domains and i
> was wondering how i would host both domains on my computer so both domains
> can point to separate index.html pages and be totally independent of each
> other. Example: so www.mydomain.com points to a different site
> then www.mydomain2.com would this be done my adding entries into the
> namedb directory. Also, i know that virtual hosts has to be done within
> httpd.conf but i'm not to sure how to go about that. Any clue on how i can
> go about setting up virtual hosts along with having multiple domains being
> hosted off my local machine instead of someone else. Thank you, all advice
> is welcome. Look forward to hearing from some people. Once again all ideas
> are greatly apperciated.
*** First of all, please break your lines at about 72 characters. It makes
*** it much easier to respond - and that's what you want, don't you?
Secondly, there are examples of virtual hosts at the end of the
httpd.conf file that is delivered with Apache.
Third, but, since they may be a little overkill and thus hard to understand,
here is something of an example of ones we use on the servers we support,
many of which have lots of virtual hosts.
Note: we use a separate IP address for each on most of the sites so
this example assumes that. It is not necessary but the setup is a little
- The netmask for aliases for a NIC that has already been config-ed with
its main address is always 255.255.255.255
- Aliases for a given NIC need to be numbered in order with none left
out - alias0 alias1, etc.
Example rc.conf entries:
# main config for fxp0
ifconfig_xl0="inet 188.8.131.52 netmask 255.255.255.0"
# virtual host IP and web server for mydom2.com
ifconfig_fxp0_alias0="184.108.40.206 netmask 255.255.255.255"
Note: You don't need all the alias stuff so nuke or # comment out what
you don't need. Customize the configuration as needed as per options
and handlers, etc.
Note: Using separate IPs requires alias entries in /etc/rc conf for each.
after the first.
Note: You need to make a directory to hold stuff for mydom2 somewhere.
I will assume you have an id called mydom2 and that it is /home/mydom2
and that in that id's home directory you have created a .../web directory.
ServerAdmin mydom2 at www.mydom2.com
CustomLog /home/mydom2/logs/access_log common
CustomLog /home/mydom2/logs/referer_log referer
CustomLog /home/mydom2/logs/agent_log agent
Alias /icons /home/mydom2.local/web/documents/images
Alias /images /home/mydom2.local/web/documents/images
Alias /reports /home/mydom2/reports
Alias /mois /home/mydom2/web
Alias /~mois /home/mydom2/web
ScriptAlias /cgi-bin/ /home/mydom2/cgi-bin/
AddHandler server-parsed .html
AddType text/html .html
Hope this helps,
> Regards, Matthew.
More information about the freebsd-questions