Question

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

Posted December 19, 2015 2.3k views
Linux BasicsUbuntuMiscellaneousServer OptimizationDeployment

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

Adz

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.

×
1 answer

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 blog.example.com and www.example.com you would put the files you want to serve in the coorisponding directories:

/var/www/blog.example.com/htdocs/
/var/www/www.example.com/htdocs/
Submit an Answer