thttpd is a simple, small, portable, fast, and secure HTTP server. It handles only the minimum necessary to implement HTTP/1.1. It also has a very small run-time size, since it does not fork and is very careful about memory allocation. It compiles cleanly on most any Unix-like OS.In typical use it's about as fast as the best full-featured servers sometimes faster.It goes to great lengths to protect the web server machine against attacks and breakins from other sites.
1. Install thttpd from packages.
pkg_add -v http://openbsd.secsup.org/3.8/packages/i386/thttpd-2.25b.tgz
2. You can start the server by using the line below. You will need to change the different parts of the line to your own config. -u is the user the server will run as. In OpenBSD this is _thttpd. -l is where to keep the server logs. The one below is set for no logging. -d is the directory where your document root is to go. The website your hosting. -h is the host ip you want to bind to. If you leave -h out then it will listen on all interfaces.
/usr/local/sbin/thttpd -r -u _thttpd -l /dev/null -d /var/www/htdocs/ -h 192.168.0.1
3. Put the line below in /etc/rc.local to start thttpd on reboot.
# Start thtppd if [ -x /usr/local/sbin/thttpd ]; then echo -n ' thttpd' /usr/local/sbin/thttpd -r -u _thttpd -l /dev/null -d /var/www/htdocs/ -h 192.168.0.1 fi
If you need to compile thttpd yourself then there are a few settings (below) I like to set but to each his own. All files are in the root dir after untaring the thttpd source. What I like to set on OpenBSD are:
In config.h I change:
#define IDLE_SEND_TIMELIMIT 120
#define DEFAULT_USER "_thttpd"
#define INDEX_NAMES "index.shtml"
In version.h file remove version and software info.
In mime_types.txt file put in "shtml text/html; charset=%s"
Note: Make the dir "errors" in the root of the website and the errorcode as as the name of the file with the letters "err" in front for personalized errors. Ex. err404.html