Table of Contents
mini-httpd is a minimalistic web server designed for optimal performance, high security, and as little use of system resources as possible. Unlike most other web servers, mini-httpd does not require more than one process or system thread in order to handle an arbitrary number of requests concurrently. The current set of features includes:
mini-httpd is limited to serving static pages from the hard disk. There is no support for CGI scripts or any kind of dynamic content. If you need a more sophisticated set-up, this software is not for you. If you really, really need additional features, well, you have the source code. For further details on how to configure the web server, refer to the section "Setting up mini-httpd" section below.
Setting up mini-httpd is pretty easy, because the program does have the least possible set of features. It may look weird at first, especially if you know other web servers like Apache, but it’s really not that difficult. The following instructions assume you’ve installed mini-httpd using the default prefix, /usr/local/mini-httpd. Not that it matters much, though, because you can set all paths at the command line.
It’s important to understand that mini-httpd changes the process’s root directory to /usr/local/mini-httpd once it has initialized its internals. Thus, all files related to your web service must reside within this directory (or below). You cannot symlink to some path outside that hierarchy, or some thing.
First of all, choose an user id you’ll run mini-httpd under. A sensible choice is daemon, but you can as well use nobody or any other user id you see fit. Find out which numeric user id this user has on your system by calling the id(1) command:
$ id daemon uid=2(daemon) gid=2(daemon) groups=2(daemon),1(bin)
Now you’ll need to create two directories in /usr/local/mini-httpd: htdocs and logs. The first directory will contain the actual web documents in one subdirectory per (virtual) host you want to provide. The second directory will contain the access logs written by mini-httpd. Consequently, mini-httpd’s user must be allowed to read htdocs and to write to logs. The following commands will ensure that:
# mkdir htdocs logs # chown daemon.daemon htdocs logs
Now create a directory in htdocs, which is called like the hostname, your web service should be provided under. Make sure you use all lower-case characters! If your web server is accessed as, say, example.com and www.example.com, do the following:
# mkdir htdocs/example.org # ln -s htdocs/example.org htdocs/www.example.org # chown daemon.daemon htdocs/example.org htdocs/www.example.org
If you’re unsure what hostname to use for testing purposes, localhost is usually a safe bet. :-)
Copy the HTML documents to the htdocs/example.org directory and ensure that mini-httpd has permission to access them! Finally, start mini-httpd as root, using the following command line:
# /usr/local/mini-httpd/bin/httpd --uid 2
That’s it. You may now direct your favorite browser to http://example.org/ and see what happens.
In case you want to try mini-httpd with some port other than 80, add the --port option to the command line: --port 8080. Furthermore, you might want to add the --debug switch to turn on the debugging messages in mini-httpd. That is particularly helpful in case mini-httpd is not behaving as you’re expecting.
Once you have accessed the web site, you’ll find the appropriate access-log file in the logs directory; one file per virtual host.
If you want to add more virtual hosts to mini-httpd, just create the corresponding directory in htdocs.
Peter Simons <simons@cryp.to>
Savannah: http://savannah.nongnu.org/projects/mini-httpd
Main web site: http://www.nongnu.org/mini-httpd/