問題描述
在 Lighttpd 中配置子域 (Configure subdomains in Lighttpd)
如果我嘗試添加子域,我將無法啟動 lighttpd。一旦我嘗試使用以下行加載配置文件,就會出現一些錯誤,但沒有更多詳細信息:
$HTTP["host"] == "sub.localhost" {
server.document‑root = "/var/www
}
子域沒有自己的文件夾。所以使用 mod_simple_vhost 是行不通的。
錯誤信息:
● lighttpd.service ‑ Lighttpd Daemon
Loaded: loaded (/lib/systemd/system/lighttpd.service; enabled; vendor preset: enabled)
Active: failed (Result: exit‑code) since So 2016‑11‑20 16:59:43 CET; 3s ago
Process: 7568 ExecStart=/usr/sbin/lighttpd ‑D ‑f /etc/lighttpd/lighttpd.conf (code=exited, status=0/SUCCESS)
Process: 26067 ExecStartPre=/usr/sbin/lighttpd ‑t ‑f /etc/lighttpd/lighttpd.conf (code=exited, status=255)
Main PID: 7568 (code=exited, status=0/SUCCESS)
Nov 20 16:59:43 mantra systemd[1]: Starting Lighttpd Daemon...
Nov 20 16:59:43 mantra lighttpd[26067]: 2016‑11‑20 16:59:43: (configfile.c.898) source: /etc/lighttpd/lighttpd.conf lin
Nov 20 16:59:43 mantra lighttpd[26067]: 2016‑11‑20 16:59:43: (configfile.c.954) configfile parser failed at: ] ==
Nov 20 16:59:43 mantra systemd[1]: lighttpd.service: Control process exited, code=exited status=255
Nov 20 16:59:43 mantra systemd[1]: Failed to start Lighttpd Daemon.
Nov 20 16:59:43 mantra systemd[1]: lighttpd.service: Unit entered failed state.
Nov 20 16:59:43 mantra systemd[1]: lighttpd.service: Failed with result 'exit‑code'.
有什麼建議嗎?
參考解法
方法 1:
The example you posted is missing a closing double‑quote at the end of the line server.document‑root = "/var/www"
That might be a typo in your post, but in any case, the error message from lighttpd reports to you the line number in your lighttpd.conf on which you had an error. Please look at that line in your lighttpd.conf and make sure the syntax is correct.
Reference: https://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_Configuration
(by user2429266、gstrauss)