Lighttpd 配置子域名
我的主域名已配置为 http://example.com,我想使用 http://support.example.com 和不同的文件。如何在 UNIX 或 Linux 操作系统下使用 Lighttpd Web 服务器添加子域名支持?
您可以按如下方式设置 lighttpd 服务器:
- example.com 将使用 /home/lighttpd/example.com/http 作为文档根目录
- support.example.com 将使用 /home/lighttpd/support.example.com/http 作为文档根目录
两个域名可以指向同一个ip地址,也可以指向不同的ip地址。编辑lighttpd.conf,输入:
# vi /etc/lighttpd/lighttpd.conf
更新/编辑如下:
server.modules = ( "mod_redirect", #"mod_alias", "mod_rewrite", "mod_expire", "mod_access", "mod_auth", "mod_status", "mod_fastcgi", "mod_secdownload", "mod_accesslog", "mod_compress", "mod_setenv", "mod_proxy", "mod_geoip" ) server.errorlog = "/var/log/lighttpd/error.log" accesslog.filename = "/var/log/lighttpd/access.log" index-file.names = ( "index.php", "index.html", "index.htm", "default.htm" ) server.tag = "lighttpd" server.document-root = "/home/lighttpd/example.com/http" server.username = "lighttpd" server.groupname = "lighttpd" server.port = "80" server.bind = "202.54.1.1." ###### Subdomain settings ############## $HTTP["host"] == "support.example.com"{ server.document-root = "/home/lighttpd/support.example.com/http" accesslog.filename = "/var/log/lighttpd/support.example.com/access.log" }
保存并关闭文件。为子域名创建所需目录:
重新加载或重新启动 lighttpd 服务器:
您现在可以将 /home/lighttpd/support.example.com/http 上的所有文件上传到 http://support.example.com/
# mkdir -p /home/lighttpd/support.example.com/http
# mkdir /var/log/lighttpd/support.example.com/
# /etc/init.d/lighttpd reload