simple-vhost.txt 2.8 KB

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