How to do i create subdomains for lighttpd ubuntu 14x?

Hi guys,

I want to know to create subdomains for my lighttpd web server, please guide me through the easiest possible way. I’ve seen few tutorials about this but half of them are outdated and other half are really hard to understand.

Ubuntu 14.x Lighttpd latest version



Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

There are a number of ways to do this, but the easiest is probably to use the “Simple Vhost” module. On Ubuntu, you can enable it by running:

sudo lighty-enable-mod simple-vhost
sudo service lighttpd force-reload

Next edit the file: /etc/lighttpd/conf-enabled/10-simple-vhost.conf Here you can set the base “server root” and the “document root.”

simple-vhost.server-root = "/var/www" 
simple-vhost.document-root = "/htdocs/" 

In this example, domains found in the /var/www directory will serve content found in the /htdocs/ directory. For example, if your sub-domains are and you would put the files you want to serve in the coorisponding directories: