操作
虚拟主机数据库¶
模块:mod_vhostdb
描述¶
(自 lighttpd 1.4.46 起)
虚拟主机数据库,用于提供虚拟主机文档根目录
选项¶
选项 | 描述 |
---|---|
vhostdb.backend | “dbi”、“ldap”、“mysql”或“pgsql” |
vhostdb.cache | 缓存参数(见下文)(自 1.4.56 起) |
vhostdb.dbi | mod_vhostdb_dbi 配置 |
vhostdb.ldap | mod_vhostdb_ldap 配置 |
vhostdb.mysql | mod_vhostdb_mysql 配置 |
vhostdb.pgsql | mod_vhostdb_pgsql 配置 |
缓存¶
vhostdb.cache = ("max-age" => "600")
(默认:未激活;无缓存)(自 lighttpd 1.4.56 起)
在内存中缓存文档根目录以减少后端负载。max-age 以秒为单位。缓存每 8 秒检查一次是否过期,因此实际缓存时间可能比配置的 max-age 长达 8 秒。
示例¶
server.modules += ( "mod_vhostdb" ) # DBI #server.modules += ( "mod_vhostdb_dbi" ) #vhostdb.backend = "dbi" #vhostdb.dbi += ( # # required # "sql" => "SELECT docroot FROM vhosts WHERE host='?' limit 1", # "dbtype" => "pgsql", # DBI database driver string name # "dbname" => "lighttpd", # # optional # "username" => "lighttpd", # (some dbtype do not require username, e.g. sqlite) # "password" => "", # (default: empty) # "socket" => "/path/sock", # (default: dbtype default) # "host" => "localhost", # (if set, overrides "socket") # "port" => 5432, # (default: dbtype default) # "encoding" => "UTF-8", # (default: dbtype default) #) # LDAP #server.modules += ( "mod_vhostdb_ldap" ) #vhostdb.backend = "ldap" #vhostdb.ldap += ( # # required # "host" => "localhost", # "filter" => "(vhost=?)", # "base-dn" => "dc=my-domain,dc=com", # base distinguished name # # optional # "attr" => "documentRoot",# (LDAP attribute with docroot; default "documentRoot") # "bind-dn" => "uid=admin,dc=my-domain,dc=com", # distinguished name to which to bind # "bind-pw" => "mysecret", # password associated with bind-dn # "ca-file" => "", # certificate authority file # "starttls" => "enable", # require TLS # "timeout" => "2000000", # network timeout in microseconds (2000000 us = 2 sec) (OpenLDAP-specific) (since 1.4.56) #) # MySQL/MariaDB #server.modules += ( "mod_vhostdb_mysql" ) #vhostdb.backend = "mysql" #vhostdb.mysql += ( # # required # "sql" => "SELECT docroot FROM vhosts WHERE host='?' limit 1", # "dbname" => "lighttpd", # "user" => "lighttpd", # # optional # "password" => "", # (default: empty) # "socket" => "/path/sock", # (default: mysql default) # "host" => "localhost", # (if set, overrides "socket") # "port" => 3306 # (default: 3306) #) # Postgres #server.modules += ( "mod_vhostdb_pgsql" ) #vhostdb.backend = "pgsql" #vhostdb.pgsql += ( # # required # "sql" => "SELECT docroot FROM vhosts WHERE host='?' limit 1", # "dbname" => "lighttpd", # "user" => "lighttpd", # (required unless dbname is a pgsql conninfo URI) # # optional # "password" => "", # (default: empty) # "host" => "localhost", # "port" => 5432 # (default: 5432) #)
相关模块¶
mod_mysql_vhost (已废弃;已被 mod_vhostdb_mysql 取代)
mod_dbi_vhost (旧版;用户贡献;效果可能因人而异)
其他¶
- 过时的文章(2010 年),使用 MySQL
Lighttpd MySQL 虚拟主机简要教程