lighttpd 1.4.x
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
2.4 KiB

MySQL bases vhosting
Module: mod_mysql_vhost
:Date: $Date: 2004/08/29 09:43:49 $
:Revision: $Revision: 1.1 $
This module provides virtual hosts (vhosts) based on a MySQL table, and
(optionally) prepares mod_fastcgi for sub-chroot FastCGI deployment.
.. meta::
:keywords: lighttpd, mysql, vhost
.. contents:: Table of Contents
vhost via mysql
Example: ::
mysql-vhost.db = "lighttpd"
mysql-vhost.user = "lighttpd"
mysql-vhost.pass = "secret"
mysql-vhost.sock = "/var/mysql.lighttpd.sock"
mysql-vhost.sql = "SELECT docroot,fcgioffset,fcgiarg FROM domains WHERE domain='?'"
MySQL setup: ::
GRANT SELECT ON lighttpd.* TO lighttpd@localhost IDENTIFIED BY 'secret';
USE lighttpd;
CREATE TABLE domains (
domain char(64) not null primary key,
docroot char(128) not null,
fcgioffset tinyint unsigned not null,
fcgiarg smallint unsigned not null
INSERT INTO domains VALUES ('host.dom.ain','/http/host.dom.ain/',5,10001);
Extra stuff: ::
fastcgi.server = ( ".php" => ( "php-fcgi" => (
"socket" => "../php/socket",
"spawn" => "/php/php-spawn"
The example above will get the docroot for a virtual host from the table, and also change the docroot for FastCGI to
be 5 (=fcgioffset) chars below the web docroot (in the example above
this means that the web docroot is /http/host.dom.ain/, while the
FastCGI docroot will be /host.dom.ain/).
The fastcgi.server "socket" is (patched to be) relative to docroot,
and the new "spawn" argument specifies a command to run to dynamically
create a new FastCGI process in case none is running (as opposed to
"bin-path" which does not dynamically create/restart FastCGI processes).
The example above will also add the argument "10001" (=fcgiarg) when
invoking the /php/php-spawn (=spawn) FastCGI spawn program. Tf the
spawn program is setuid this can be used to chroot and setgid/setuid
to the right user before exec:ing the actual FastCGI program.
NOTE: both fcgioffset and fcgiarg are optional. Just remove every
mention of them in the example above for a pure vhost server.
You can also use just fcgioffset and not fcgiarg if you like.