Docs ModVhostDbi » History » Revision 9
Revision 8 (mortanian, 2013-05-25 17:53) → Revision 9/10 (mortanian, 2014-01-08 00:15)
h1. Docs:ModDbiVhost *Module: mod_dbi_vhost* {{>toc}} h2. Description mod_dbi_vhost is a modified version of "mod_mysql_vhost":http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs:ModMysqlVhost which instead uses "libDBI":http://libdbi.sf.net/ to read vhost to document root associations. h2. Installation This module is a 3rd party module and is not included in the official distribution. You can download the patch from here: * For lighttpd 1.4.28 through 1.4.31: 1.4.28: http://fortfire.ca/~doneill/lighttpd-1.4.28-dbi.patch Once applied, run autogen.sh and pass the option @--with-dbi@ to let the GNU tools find it, or @--with-dbi=/path/to/dbi@ to specify the location. h2. Options *vhost.dbi => ( "dbname" => "..." )* - Required The name of the database for network database connections, or a database filename for local database implementations (Sqlite). *vhost.dbi => ( "dbtype" => "..." )* - Required Set this to your database type. This is usually included in the DBD file name. Eg., libdbdmysql.so is "mysql", and libdbdpgsql.so is "pgsql". Some options include: _mysql_, _pgsql_, _sqlite3_, _freetds_, _sqlite_ *vhost.dbi => ( "sql" => "..." )* - Required The actual query used to get the document root for a vhost. Use '?' in place of the hostname, for example: <pre> vhost.dbi += ( "sql" => "SELECT docroot FROM vhosts WHERE host='?'" ) </pre> h3. Common Options *vhost.dbi += ( "user" => "..." )* - Optional The username to use for opening a typical network-based database connection. *vhost.dbi += ( "pass" => "..." )* - Optional A password used to authenticate to a database connection. *vhost.dbi += ( "hostname" => "..." )* - Optional A hostname used in establishing a database connection. *vhost.dbi += ( "port" => _i_ )* - Optional A port number used to authenticate to a database connection. If not specified, the default for the specified database type will be used. h3. MySQL-Specific Options *vhost.dbi += ( "encoding" => "..." )* - Optional For example, "@UTF-8@". This parameter compatibility and available options depend on the driver. I use it to tell the MySQL DBD to use UTF-8. h3. Sqlite3-Specific Options *vhost.dbi += ( "sqlite3_dbdir" => "..." )* - Required The directory on the filesystem where the database file (specified in "dbname") is located. h2. Examples <pre># Sqlite3 vhost.dbi += ( "dbtype" => "sqlite3", "dbname" => "lighttpd.db", "sqlite3_dbdir" => "/etc/lighttpd", "encoding" => "UTF-8", "sql" => "SELECT docroot FROM vhosts WHERE host='?'" ) # PostgreSQL vhost.dbi += ( "dbtype" => "pgsql", "dbname" => "lighttpd", "user" => "postgres", "hostname" => "localhost", "encoding" => "UTF-8", "sql" => "SELECT docroot FROM vhosts WHERE host='?'" ) # MySQL vhost.dbi += ( "dbtype" => "mysql", "dbname" => "lighttpd", "user" => "root", "password" => "somepassword", "hostname" => "localhost", "encoding" => "UTF-8", "sql" => "SELECT docroot FROM vhosts WHERE host='?'" ) server.modules += ( "mod_dbi_vhost" ) </pre>