Lighttpd配置子域
时间:2020-01-09 10:42:22 来源:igfitidea点击:
我已经在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 = "192.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"
}
保存并关闭文件。
创建子域所需的目录:
# mkdir -p /home/lighttpd/support.example.com/http # mkdir /var/log/lighttpd/support.example.com/
重新加载或者重启lighttpd服务器:
# /etc/init.d/lighttpd reload
您现在可以在/home/lighttpd/support.example.com/http上将所有文件上传到http://support.example.com/

