Here a quick how to, about how to configure Lighttpd to run with Virtualhosts.
This has been installed and tested on a Raspberry Pi.
apt-get install lighttpd php5 php5-cgi
Enable modules:
lighttpd-enable-mod auth cgi fastcgi fastcgi-php nagios3 simple-vhost ssl status
Content of /etc/lighttpd/lighttpd.conf
server.modules = ( "mod_access", "mod_alias", "mod_compress", "mod_redirect", # "mod_rewrite", ) server.document-root = "/var/www" server.upload-dirs = ( "/var/cache/lighttpd/uploads" ) server.errorlog = "/var/log/lighttpd/error.log" server.pid-file = "/var/run/lighttpd.pid" server.username = "www-data" server.groupname = "www-data" server.port = 80 index-file.names = ( "index.php", "index.html", "index.lighttpd.html" ) url.access-deny = ( "~", ".inc" ) static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" ) compress.cache-dir = "/var/cache/lighttpd/compress/" compress.filetype = ( "application/javascript", "text/css", "text/html", "text/plain" ) # default listening port for IPv6 falls back to the IPv4 port include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port include_shell "/usr/share/lighttpd/create-mime.assign.pl" include_shell "/usr/share/lighttpd/include-conf-enabled.pl"
To easily manage virtual hosts, edit /etc/lighttpd/conf-available/10-simple-vhost.conf
server.modules += ( "mod_simple_vhost" ) simple-vhost.server-root = "/var/www/vhost" simple-vhost.default-host = "error.default.loc" simple-vhost.document-root = "/"
This configuration above will allow you to manage your virutalhosts simply storing them in a folder under /var/www/vhost
No extra configuration is needed from the server side.
Simply go into /var/www/vhost
and create a folder named as the virtualhost you would like to manage.
In this particular case, please make sure to have a folder called error.default.loc
with a page inside which will be displayed in case of ANY error.
For example, if you want to manage mysite.example.com, simply do the following:
cd /var/www/vhost mkdir mysite.example.com chown www-data:www-data mysite.example.com
…and put the html/php files inside that new folder! 🙂
To test if our webserver works, you can always use curl
command as explained here.