To configure a subdomain in Lighttpd, you can use the $HTTP["host"]
directive in the Lighttpd configuration file, typically located at /etc/lighttpd/lighttpd.conf
.
Here is an example of how to configure a subdomain named sub.example.com
in Lighttpd:
$HTTP["host"] == "sub.example.com" { server.document-root = "/var/www/sub.example.com" }
This will set the document root for the subdomain to /var/www/sub.example.com
. Replace this path with the path to the directory that contains the files for the subdomain on your system.
You can also use the $HTTP["host"]
directive to specify different configurations for different subdomains. For example, to specify a different document root for the subdomain blog.example.com
, you can add the following lines to the configuration file:
$HTTP["host"] == "blog.example.com" { server.document-root = "/var/www/blog.example.com" }
To apply the changes, you will need to restart Lighttpd. On most systems, you can use the following command to restart Lighttpd:
sudo systemctl restart lighttpd
Keep in mind that you will also need to set up DNS records for the subdomain and point them to the IP address of the server where Lighttpd is running. Consult your DNS provider's documentation for instructions on how to set up DNS records for a subdomain.