1====================== 2Simple Virtual-Hosting 3====================== 4 5------------------------ 6Module: mod_simple_vhost 7------------------------ 8 9:Author: Jan Kneschke 10:Date: $Date: 2004/08/29 09:43:49 $ 11:Revision: $Revision: 1.1 $ 12 13:abstract: 14 virtual hosting 15 16.. meta:: 17 :keywords: lighttpd, virtual hosting 18 19.. contents:: Table of Contents 20 21Description 22=========== 23 24Simple assumption: 25 26Every virtual host is in a directory below a base directory in a path that 27is the same as the name of the vhost. Below this vhost path might be an 28extra directory which is the document root of the vhost. 29 30The document root for each vhost is built from three values: 31 32- server-root 33- hostname 34- document-root 35 36The complete document root is constructed either by :: 37 38 server-root + hostname + document-root 39 40or if this path does not exist by :: 41 42 server-root + default-host + document-root 43 44A small example should make this idea clear: :: 45 46 /var/www/ 47 /var/www/logs/ 48 /var/www/servers/ 49 /var/www/servers/www.example.org/ 50 /var/www/servers/www.example.org/lib/ 51 /var/www/servers/www.example.org/pages/ 52 /var/www/servers/mail.example.org/ 53 /var/www/servers/mail.example.org/lib/ 54 /var/www/servers/mail.example.org/pages/ 55 56 simple-vhost.server-root = "/var/www/servers/" 57 simple-vhost.default-host = "www.example.org" 58 simple-vhost.document-root = "pages" 59 60You can use symbolic links to map several hostnames to the same directory. 61 62Conditionals vs. simple-vhost 63----------------------------- 64 65You have to keep in mind that conditionals and simple-vhost interfere 66with one another. :: 67 68 simple-vhost.server-root = "/var/www/servers/" 69 simple-vhost.default-host = "www.example.org" 70 simple-vhost.document-root = "pages" 71 72 $HTTP["host"] == "news.example.org" { 73 server.document-root = "/var/www/servers/news2.example.org/pages/" 74 } 75 76When ``news.example.org`` is requested, the ``server.document-root`` 77will be set to ``/var/www/servers/news2.example.org/pages/``, but 78simple-vhost will overwrite it shortly afterwards. 79 80If ``/var/www/servers/news.example.org/pages/`` exists, that will be 81used. If not, ``/var/www/servers/www.example.org/pages/`` will be taken 82because it is the default. 83 84To use conditionals together with simple-vhost, you should do this: :: 85 86 $HTTP["host"] !~ "^(news\.example\.org)$" { 87 simple-vhost.server-root = "/var/www/servers/" 88 simple-vhost.default-host = "www.example.org" 89 simple-vhost.document-root = "pages" 90 } 91 92 $HTTP["host"] == "news.example.org" { 93 server.document-root = "/var/www/servers/news2.example.org/pages/" 94 } 95 96It will enable simple vhosting for all hosts other than ``news.example.org``. 97 98Options 99======= 100 101simple-vhost.server-root 102 root of the virtual host 103 104simple-vhost.default-host 105 use this hostname if the requested hostname does not have its own directory 106 107simple-vhost.document-root 108 path below the vhost directory 109 110