Lighttpd Configure Subdomain

I‘ve main domain configured at and I’d like to use 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:

  • will use /home/lighttpd/ as document root
  • will use /home/lighttpd/ 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              = (
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/"
server.username = "lighttpd"
server.groupname = "lighttpd"
server.port = "80"
server.bind = ""  
###### Subdomain settings ##############
$HTTP["host"]  == ""{
        server.document-root = "/home/lighttpd/"
        accesslog.filename         = "/var/log/lighttpd/"

Save and close the file. Create required directories for subdomain:
# mkdir -p /home/lighttpd/
# mkdir /var/log/lighttpd/

Reload or restart the lighttpd server:
# /etc/init.d/lighttpd reload
You can now upload all files at /home/lighttpd/ for

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 2 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
2 comments… add one
  • dootzky May 27, 2014 @ 16:23

    thank you! :)

    it worked! :D even 3 years later! ^_^

  • ivo Nov 8, 2015 @ 8:06

    I’ve been struggeling to get this to work with a subdomain on an other server.
    Can you give an example where it routes the subdomain to an other server while using only one public IP.
    To clarify a bit:
    public IP goes to and blog.mydomain.
    server 1 hosts (internal ip
    server 2 hosts (internal ip
    server 1 is dmz (so lands you on server 1)

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum