Monday, April 23, 2012

Lighttpd Configure Subdomain

I've main domain configured at http://example.com and I'd like to use http://support.example.com with different files. How do I add subdomain support with Lighttpd web server under UNIX or Linux operating systems?

You can setup lighttpd server as follows:
  • example.com will use /home/lighttpd/example.com/http as document root
  • support.example.com will use /home/lighttpd/support.example.com/http as document root
Both domain can point to the same ip address or different ip address. Edit lighttpd.conf, enter:
# vi /etc/lighttpd/lighttpd.conf
Update / edit as follows:
 
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"
}
 
Save and close the file. Create required directories for subdomain:
# mkdir -p /home/lighttpd/support.example.com/http
# mkdir /var/log/lighttpd/support.example.com/

Reload or restart the lighttpd server:
# /etc/init.d/lighttpd reload

No comments:

Post a Comment