Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 May 2003 10:12:50 -0400 (EDT)
From:      Jerry McAllister <jerrymc@clunix.cl.msu.edu>
To:        unixparse@yahoo.com (Matthew L)
Cc:        questions@freebsd.org
Subject:   Re: Regarding Virtual Hosts & Domains
Message-ID:  <200305191412.h4JECo4A014049@clunix.cl.msu.edu>
In-Reply-To: <20030518033308.13563.qmail@web9505.mail.yahoo.com> from "Matthew L" at May 17, 2003 08:33:08 PM

next in thread | previous in thread | raw e-mail | index | archive | help
> 
> Hi,
>  
>     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
different.  
in /etc/rc.conf:
- 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 33.3.3.3 netmask 255.255.255.0"

 # virtual host IP and web server for mydom2.com
 ifconfig_fxp0_alias0="33.3.3.32 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.

<VirtualHost 33.3.3.32:80>
Listen 33.3.3.32:80
       ServerAdmin mydom2@www.mydom2.com
       DocumentRoot /home/mydom2/web
       ServerName www.mydom2.com
       ErrorLog /home/mydom2/logs/error_log
       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/
       AccessFileName .htaccess
       <Directory /home/mydom2/web>
       AddHandler server-parsed .html
       AddType text/html .html
       Options +Includes
       </Directory>
       <Directory /home/mydom2/web/members>
       AllowOverride All
       </Directory>
</VirtualHost>

Hope this helps,

////jerry

>  
> Regards, Matthew.
> 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200305191412.h4JECo4A014049>