13.06.2015 Views

Introduction to the Apache Web Server - ApacheCon

Introduction to the Apache Web Server - ApacheCon

Introduction to the Apache Web Server - ApacheCon

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

6.5.4 mod vhost alias<br />

At this point in <strong>the</strong> course, if we have time, we’ll experiment with mod vhost alias, which is a module<br />

allowing bulk virtual hosting. You’ll find a sample configuration in <strong>the</strong> examples direc<strong>to</strong>ry on your CD,<br />

which should look something like this:<br />

VirtualDocumentRoot /usr/local/apache/vhosts/%1.1/%1.2/%1.3+/htdocs<br />

VirtualScriptAlias /usr/local/apache/vhosts/%1.1/%1.2/%1.3+/cgi-bin<br />

As this is primarily a hands-on experiment, little space is given <strong>to</strong> this in <strong>the</strong> notes. Please see<br />

http://httpd.apache.org/docs-2.0/mod/mod vhost alias.html for more information.<br />

Students tend <strong>to</strong> want more experimentation here, so I’ve attempted <strong>to</strong> add some better examples that <strong>the</strong>y<br />

can play with. Have <strong>the</strong>m try one or more of <strong>the</strong> following:<br />

VirtualDocumentRoot /usr/local/apache/vhosts/%2/%1/htdocs<br />

Which should map www.foo.com <strong>to</strong> /usr/local/apache/vhosts/foo/www/htdocs and bob.foo.com <strong>to</strong><br />

/usr/local/apache/vhosts/foo/bob/htdocs<br />

or ...<br />

VirtualDocumentRoot /usr/local/apache/vhosts/%1.1/%1.2+/htdocs<br />

Which should mapwww.foo.com <strong>to</strong>/usr/local/apache/vhosts/w/ww/htdocsandbob.foo.com <strong>to</strong>/usr/local/apache/vho<br />

In order <strong>to</strong> actually try <strong>the</strong>se things, <strong>the</strong>y will need <strong>to</strong> create a lot of direc<strong>to</strong>ries and add a lot of hostfile<br />

entries. This is only useful in practice for wildcard DNS entries.<br />

35

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!