[ english | italian ]

SHTTPD (Simple HTTPD)

Overview

SHTTPD is a lightweight, easy to use web server. Ideal for web developers, web-based software demos (like PHP, Perl etc), quick file sharing. It also can be used as a library that provides web server functionality, to create web interface for C/C++ applications. SHTTPD is licensed under the terms of beerware license.

Download

Get the latest version. Read the manual.

Features

Absent features: virtual hosts, user home directorires, SSI (server side includes), ACL (access control lists), traffic shaping, keep-alive connections, FCGI (Fast CGI) support.

Screenshots (Windows GUI)

Systray iconSettings windowLog window

Setting secure web (HTTPS)

Below I describe how to set up HTTPS on Windows. Download libssl32.dll and libeay32.dll. Copy them to your windows directory, C:\windows. Download SSL certificate file, shttpd.pem, put it on C:\shttpd.pem. On a GUI, set the "SSL certificate file" option to point at C:\shttpd.pem. Save settings. That's all.

Making a proxy server out from SHTTPD

Install Perl on your machine. Download nph-proxy.cgi perl script, developed by James Marshall. Start shttpd, set the option "CGI interpreter" to perl.exe binary. In a browser, type in the URL where nph-proxy.cgi lives. That's all.

Embedding SHTTPD into existing application

Download the source package. Extract it, go to src directory. Run "make unix" there ("nmake win" on Windows, requires MSVC). That buillds a library. The API is defined in shttpd.h header file. Use the API functions in your application, link the application against the library. There are couple of examples in the source package you can refer to.

Issues I came across (useful tips for developers)

  1. Compiling for embedded Linux, ARM + uclibc does not work. This is due to the buggy implementation of sscanf() and snprintf() stdio functions in uClibc. To fix that, use alternate implementations of these functions, such as Trio, written by Daniel Stenberg. You gonna need to re- #define snprintf to trio_snrpintf, sscanf to trio_sscanf. The compilation line then would be
    arm-elf-gcc -o shttpd shttpd.c trio.c triostr.c
    It has been reported that other small webservers do not work too when compiled against uClibc for ARM. sscanf() fix might help to address that problem.
  2. CGI execution under Windows. Once upon a time I ran a perl CGI script under SHTTPD. That script supposed to connect to a MySQL database server and to show some data. I have got this error:
    Can't create TCP/IP socket (10106)
    The same I have got running similar PHP script:
    mysql_connect(): Can't create TCP/IP socket (10106)
    After hours of debugging I realised that the web server (in this case, SHTTPD) must pass SYSTEMROOT environment variable to the child CGI process, unless the child process cannot perform any socket operation. Thank Microsoft for this funny feature.

License

 "THE BEER-WARE LICENSE" (Revision 42):
 Sergey Lyubka wrote this software. As long as you retain this notice you
 can do whatever you want with this stuff. If we meet some day, and you think
 this stuff is worth it, you can buy me a beer in return.

Links

Acknowledgements

Author

Copyright © by Sergey Lyubka (shttpd-general at lists dot sourceforge dot net). You can keep me happy by reducing my books wishlist.