Darkhttpd

From Alpine Linux
Revision as of 14:54, 15 January 2014 by Ginjachris (talk | contribs) (Created page with "{{Draft}} Darkhttpd is a simple, fast web server for static content. It does not support PHP or CGI etc but is designed to serve static content, which it does very well. ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Underconstruction clock icon gray.svg
This material is work-in-progress ...

Do not follow instructions here until this notice is removed.
(Last edited by Ginjachris on 15 Jan 2014.)

Darkhttpd is a simple, fast web server for static content. It does not support PHP or CGI etc but is designed to serve static content, which it does very well.

For a full list of features see the [darkhttpd homepage]

Install

apk add darkhttpd

Configure

Default location of files to serve: /var/www/localhost/hdocs

Default log path: /var/log/darkhttpd/access.log

There's no configration file for darkhttpd, everything is controlled from the command line or in our case the OpenRC init file, which is stored in /etc/init.d/darkhttpd and by default looks like this:

#! /sbin/runscript

description="darkhttpd web server"
command="/usr/bin/darkhttpd"
command_args="${document_root:-/var/www/localhost/htdocs} --chroot --daemon --uid darkhttpd --gid www-data --log /var/log/darkhttpd/access.log"
procname="darkhttpd"
pidfile=""
stopsig="SIGTERM"

So by default we will serve pages from /var/www/localhost/hdocs and darkhttpd will run as a background daemon, chrooted to /var/www/localhost/hdocs with a user of 'darkhttpd' and group of 'www-data'. Logs will go to /var/log/darkhttpd/access.log. The default values have been chosen to provide sane, secure settings.

Change any of these values as you see fit, but it's a good idea to backup the file before making changes.

For a full list of available options, run:

darkhttpd

and amend the command_args line as you see fit.

Use

Create a test page under /var/www/localhost/hdocs

echo "this is a test page" > /var/www/localhost/htdocs/index.html

Note: You don't have to create a test page; in a working environment darkhttpd will generate a directory listing if no index page is found.

Start the daemon:

rc-service darkhttpd start

Output should be something like this:

 * Starting darkhttpd ...
darkhttpd/1.9, copyright (c) 2003-2013 Emil Mikulic.
listening on: http://0.0.0.0:80/
chrooted to `/var/www/localhost/htdocs'
set gid to 82
set uid to 100                                

Now point a browser to your darkhttpd server and you should get the index page (or a directory listing if you didn't create an index page).

Check the logfile:

tail /var/log/darkhttpd/access.log

Stop, start and restart the daemon in the usual fashion:

rc-service darkhttpd start

rc-service darkhttpd stop

rc-service darkhttpd restart

To add the daemon to the default runlevel so it auto-starts at boot, do:

rc-update add darkhttpd

In production, filesharing is made easy; simply add your files under /var/www/localhost/hdocs

Darkhttpd would be an excellent alternative to Lighttpd for running an Alpine mirror