Skip to content

Latest commit

 

History

History
92 lines (66 loc) · 3.05 KB

File metadata and controls

92 lines (66 loc) · 3.05 KB

Installation

simple-httpd is a single binary. Build it from source; packaging templates exist but are not the supported install path yet.

Requirements

Piece Notes
C++17 compiler Clang, GCC, or MSVC
CMake 3.16 or newer
Threads POSIX threads or Win32
OpenSSL Optional; required for HTTPS (ENABLE_SSL)
zlib Optional; required for gzip
nghttp2 Optional; required for HTTP/2 (ENABLE_HTTP2)

On macOS, Xcode command-line tools plus OpenSSL and nghttp2 (Homebrew openssl / libnghttp2) are typical. On Debian/Ubuntu: build-essential cmake libssl-dev zlib1g-dev libnghttp2-dev.

Configure and build

cmake -S . -B build \
  -DCMAKE_BUILD_TYPE=Release \
  -DENABLE_PACKAGING=OFF \
  -DENABLE_SSL=ON \
  -DENABLE_HTTP2=ON \
  -DENABLE_TESTS=ON
cmake --build build

If an old CMake cache left ENABLE_SSL=OFF, reconfigure with -DENABLE_SSL=ON. OpenSSL is used only when CMake finds it; otherwise the build continues without TLS.

Equivalent: make build.

CMake options

Option Default Meaning
ENABLE_SSL ON Link OpenSSL when found
ENABLE_HTTP2 ON Link nghttp2 when found
ENABLE_TESTS ON Build ctest binaries
ENABLE_PACKAGING ON Include CPack templates (safe to turn off)
ENABLE_STATIC_LINKING OFF Static libgcc/libstdc++ on GCC
ENABLE_JSON OFF Unused by the daemon; leave off
BUILD_SHARED_LIBS OFF The server library is built static

gzip is enabled automatically when zlib is found (SIMPLE_HTTPD_ENABLE_ZLIB). HTTP/2 is enabled when nghttp2 is found (SIMPLE_HTTPD_ENABLE_HTTP2). There is no separate switch for gzip.

Product version is the first line of VERSION. CMake reads it; you do not pass it on the command line.

Test

ctest --test-dir build --output-on-failure

Or make test. Tests include a live HTTP server on an ephemeral port and, when OpenSSL is present, a self-signed HTTPS exchange.

Run without installing

./build/simple-httpd --root www --port 8080
./build/simple-httpd --help
./build/simple-httpd --version

The binary name is simple-httpd (simple-httpd.exe on Windows).

Install

cmake --install build --prefix /usr/local

This installs the binary to bin/ and example configs toward etc/simple-httpd/. On Linux it may also install a systemd unit from deployment/systemd/ if the templated filename is present.

Typical layout after you place files yourself:

/usr/local/bin/simple-httpd
/etc/simple-httpd/simple-httpd.conf
/etc/simple-httpd/tls/fullchain.pem
/etc/simple-httpd/tls/privkey.pem
/var/www/html
/var/log/simple-httpd/access.log
/var/log/simple-httpd/error.log

Service wrappers: operations.md and ../deployment/README.md.

Platforms

The code is written for Linux, macOS, and Windows (Winsock). Day-to-day development and tests run on Unix-like systems. Windows is compiled in spirit (ws2_32, _WIN32 branches) but is not the primary CI target.