Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 Mar 1997 15:42:42 -0600
From:      "Jeffrey J. Mountin" <sysop@mixcom.com>
To:        Wes Hester <software@crosslogic.com>
Cc:        questions@FreeBSD.ORG
Subject:   Re: Virtual Servers on FreeBSD
Message-ID:  <3.0.32.19970312154242.01157f04@mixcom.com>

next in thread | raw e-mail | index | archive | help
At 11:22 PM 3/11/97 +0000, Wes Hester wrote:
>Help..I am running FreeBSD and an Apache Web Server.  I currently have the
>OS and
>Apache Web Server working.  My problem is that I am now trying to configure
>an additional domain to the web server...a virtual server.  Does anyone have
>any help to offer in configuring the FreeBSD files with the Apache Server to
>create virtual servers?

The most common way is to bind another IP (you can do virtual hosts on the
same IP).

As an example:  server root is /httpd and document root is /httpd/htdocs
the server is www.my.com (1.2.3.1) and all IPs are on a class C

First edit /etc/rc.local so that on startup the IP(s) are bound and the
server starts.  For more than one a loop is helpful:

while :
do
	read LINE
	if [ $? -ne 0 ] ; then
		break
	fi

	ifconfig ed0 inet $LINE netmask 255.255.255.255 alias

done << EOF
1.2.3.2
1.2.3.3 (etc)...
EOF

/httpd/conf/apache_1.1.1 -d /httpd -f conf/httpd.conf


Edit the httpd.conf file:

# 1.2.3.2
<VirtualHost www.customer1.com>
ServerName www.customer1.com
ServerAdmin customer1@mixcom.com
DocumentRoot /httpd/htdocs/customer1
ErrorLog /httpd/logs/customer1.error
TransferLog /httpd/logs/customer1.access
</VirtualHost>


Also make sure that the 'BindAddress *' is set in httpd.conf.


If you aren't restarting the server, then manually do the ifconig:

ifconfig ed0 alias 1.2.3.2

Note you don't need the netmask if it is an IP from a C class that is not
subnetted.

Make sure you have a /httpd/htdocs/customer directory and either stop/start
or HUP the server.


You can do this without consuming IP addresses, but it seems to give the
customer that warm fuzzy feeling when they have their own IP.

Basically you do the same thing withoug binding a new IP, but use the
server's IP.  We have a server www.mixcom.com and our site is the same
thing, so the server root and documemnt root are /httpd and /httpd/htdocs
respectively, but www.mixcom.com has /httpd/htdocs/mixcom for the document
root.  At one point we used the server's doc root, but then customers could
do http://www.mixcom.com/customer1 and avoid traffic fees.  Had to fix
that.  ;)


-------------------------------------------
Jeff Mountin - System/Network Administrator
jeff@mixcom.net

MIX Communications
Serving the Internet since 1990



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