Lighttpd virtual hosting

Sat, Jun 13, 2009

Linux

Virtual hosting allows you to host many websites from one server.

    Setup The Folders and users

  1. adduser domain1
    addgroup domain1
    adduser www-data domain1
    mkdir -p /home/domain1
    chown domain1:domain1 -R /home/domain1
    chmod 750 -R /home/domain1

    adduser domain2
    addgroup domain2
    adduser www-data domain2
    mkdir -p /home/domain2
    chown domain2:domain2 -R /home/domain2
    chmod 750 -R /home/domain2

    Lighttpd Config

  1. Open your lighttpd.conf
    nano /etc/lighttpd.conf
  2. Add the following for the virtual host configuration
    $HTTP["host"] == "domain1.com" {
    server.document-root = "/home/domain1"
    accesslog.filename = "/var/log/lighttpd/domain1/access.log"
    }

    $HTTP["host"] == "domain2.com" {
    server.document-root = "/home/domain2"
    accesslog.filename = "/var/log/lighttpd/domain2/access.log"
    }
  3. Save your config and restart lighttpd
    /etc/init.d/lighttpd restart
, , , , , , ,

This post was written by:

Duffy - who has written 48 posts on Tuts4Tech.

I am the owner of this website, please feel free to ask me any questions you have

Contact the author

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

Leave a Reply