Lighttpd configure domain and subdomain

Posted on January 19, 2014 at 11:17 pm

We have a domain “example.com” and a subdomain “sub.example.com”.

Create a file named “example.com.conf” in /etc/lighttpd/ directory:

$HTTP["host"] =~ "(^www\.example\.com|^example\.com)" {
server.document-root = "/var/www/example.com/public/htdocs"
server.errorlog = "/var/www/example.com/logs/error.log"
accesslog.filename = "/var/www/example.com/logs/access.log"
}

Create a file named “sub.example.com.conf” in /etc/lighttpd/ directory:

$HTTP["host"] == "sub.example.com" {
server.document-root = "/var/www/sub.example.com/public/htdocs"
server.errorlog = "/var/www/sub.example.com/logs/error.log"
accesslog.filename = "/var/www/sub.example.com/logs/access.log"
}

Note, we use regular expressions only to configure the domain.

Append these two lines in the file /etc/lighttpd/lighttpd.conf:

include "example.com.conf"
include "sub.example.com.conf"

Restart Lighttpd:

/etc/init.d/lighttpd restart

Updated on January 21, 2014 at 9:36 am

Other Posts

Updated Posts