操作
Lighttpd 配置布局¶
应用程序的配置文件也可以像 djbdns 类似地放置在服务目录下。得益于 Lighttpd 的 include 指令,您的配置可以拆分为更小的部分,放入子目录,甚至可以在多个 Lighttpd 服务实例之间共享。
同样,通过将环境变量替换指令(“env.*”)与 envdir 程序结合使用,您的配置几乎可以无限地模块化。
术语“服务实例”指的是您的服务器上可以完美运行多个 Lighttpd 实例,每个实例在不同的 IP/端口上以不同的权限运行。
示例 1¶
继续 LighttpdUnderSupervise 中使用的示例
/srv/lighttpd-main/ /srv/lighttpd-main/root/ # root directory of the lighttpd configuration /srv/lighttpd-main/root/common/ -> /etc/lighttpd/common/ # symlink pointing to a shared directory /srv/lighttpd-main/root/htdocs/ # default website root /srv/lighttpd-main/root/sites/ # vhost configuration files
文件 ./run¶
#! /bin/sh exec 2>&1 exec softlimit -m 700000000 /usr/sbin/lighttpd -D -f ./root/lighttpd.conf
文件 ./root/lighttpd.conf¶
因为我们使用了 -f 参数,所以其他包含文件的基础路径将是 /srv/lighttpd-main/root/。
include "modules.inc" include "common/common.inc" # default site server.bind = "192.168.8.160" include "sites/default" # "Multiple bind" hack $SERVER["socket"] == "132.12.21.20:80" { include "sites/foo.com" } $SERVER["socket"] == "132.12.21.21:80" { include "sites/foo.co.jp" } $SERVER["socket"] == "132.12.21.22:80" { include "sites/foo.se" }
文件 ./root/modules.conf¶
server.modules = ( "mod_rewrite", "mod_alias", ...
文件 ./root/common/common.inc¶
# server.pid-file is not needed server.username = "www-data" #server.max-keep-alive-idle = 30 ...
文件 ./root/sites/default¶
server.document-root = "./root/htdocs/" # default website root status.status-url = "/server-status" ...
文件 ./root/sites/foo.com¶
# No $HTTP["host"] match required in this example since this site # file was included from within a $SERVER["socket"] stanza... server.document-root = /home/foo.com/wwwroot/ ...