Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 22 Apr 2000 01:24:09 -0600 (CST)
From:      Ryan Thompson <ryan@sasknow.com>
To:        webmaster <admin@rustikat.com>
Cc:        freebsd-questions@FreeBSD.ORG
Subject:   Re: Web Server
Message-ID:  <Pine.BSF.4.21.0004220108000.18268-100000@ren.sasknow.com>
In-Reply-To: <200004220648.CAA21492@rustikat.com>

next in thread | previous in thread | raw e-mail | index | archive | help
webmaster wrote to freebsd-questions@FreeBSD.ORG:

> Gentlemen
> I have a web server set up using the FreeBSD OS
> I need to create a virtual site
> www.mydomain.com
> Can't find instructions on how to do this
> Please help a newbie
> Thanks
> Fred

The Apache documentation would be an excellent place to start.  It should
be installed on your system.  If not, it can be found under
http://www.apache.org/

Virtual hosting is a broad topic with an assortment of different "options"
in terms of implementation.  Perhaps the most important distinction is the
difference between name-based virtual hosting (many domains on one IP
address), or IP based virtual hosting (one-to-one mapping of domain to IP
address).  Unless you are an ISP with your own large block of addresses,
or your ISP has delegated a fairly large block to you, you will probably
want to utilize name-based virtual hosting.  As well, name-based virtual
hosting typically uses far fewer file handles and socket bindings, so it
is generally easier on system resources.  It also preserves network
addresses.

As an example of name based virtual hosting, we will assume you have a
public network address 172.16.0.1 (actually, that's a non
Internet-routable private address.  Please don't use it ;-)  You currently
have www.currentdomain.com pointed at 172.16.0.1.  Now, you also have
www.mydomain.com pointed at 172.16.0.1.  This is a DNS issue.  If you do
your own DNS, you will of course have to create a zone file for
mydomain.com and point the 'www' host to 172.16.0.1.  If your ISP does
your DNS for you, kindly ask them to do the same.  The convention is often
to also point mydomain.com at the same address for virtual hosts.  (So
they both forward resolve to 172.16.0.1).  The reverse entry for name
based virtuals is often nonsensical. :-)  It should usually resolve to a
host at your "primary" corporate domain. DNS is beyond the scope of your
query, and this message, so please ask if you have a specific problem with
hostname lookups.

Now, in your httpd.conf, you need to add a <VirtualHost> container,
something like the following:


# The following line causes Apache to listen on the given network
# address and port number.  The :80 is usually implied, unless you've
# told Apache to bind to a nonstandard port in the default container.

NameVirtualHost 172.16.0.1:80


<VirtualHost 172.16.0.1:80>
        ServerAdmin     webmaster@mydomain.com
        DocumentRoot    /www/mydomain/public_html
        ServerName      www.mydomain.com
        ServerAlias     mydomain.com
</VirtualHost>          


Note that you can also add things like custom logs, scriptaliases, and
locations inside <VirtualHost> containers.  Consult the Apache
documentation for examples and further instructions.

Of course, after adding those lines to httpd.conf, you will need to
restart Apache.  Running `apachectl graceful` will nicely tell Apache to
reload its config files and restart server processes as they become idle.

Hope this helps,
- Ryan

-- 
  Ryan Thompson <ryan@sasknow.com>
  Systems Administrator, Accounts
  Phone: +1 (306) 664-1161

  SaskNow Technologies     http://www.sasknow.com
  #106-380 3120 8th St E   Saskatoon, SK  S7H 0W2



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0004220108000.18268-100000>