Strix is a lightweight, multi-threaded web server framework built in modern C++ with cross-platform support for macOS, Linux, and Windows.
- HTTPS Support: Runs on
https://127.0.0.1:8080/
with self-signed certificates. - Cross-Platform: Compatible with macOS, Linux, and Windows using platform-specific socket handling.
- Modern C++: Leverages C++23 features like concepts and
<string_view>
for efficiency. - Thread Pool: Handles multiple connections concurrently with a configurable thread pool.
- Virtual Hosts: Supports routing based on hostnames.
- Static File Serving: Serves files from a specified directory.
- CMake: Version 3.10 or higher for building the project.
- OpenSSL: Required for HTTPS support.
- macOS:
brew install openssl
- Linux:
sudo apt-get install libssl-dev
(Ubuntu) orsudo yum install openssl-devel
(CentOS) - Windows: Install via vcpkg or download from OpenSSL binaries
- macOS:
- C++ Compiler: Must support C++23 (e.g., GCC 13+, Clang 16+, MSVC 2022+).
- macOS: Install Xcode or
xcode-select --install
for Clang. - Linux:
sudo apt-get install g++
or equivalent. - Windows: Visual Studio 2022 with C++ tools or MinGW-w64.
- macOS: Install Xcode or
- Git: For cloning the repository.
git clone https://github.com/genyleap/strix.git
cd strix
- You can use bootstrap method via PT project template.
mkdir build
cd build
cmake .. -DUSE_JSON=true -DUSE_OPENSSL=true -DDUSE_ZLIB=true
make
-
Install Dependencies:
brew install cmake openssl
Ensure OpenSSL is in your path (e.g.,
/usr/local/opt/openssl
). -
Generate Build Files:
mkdir build && cd build cmake -G "Unix Makefiles" -DCMAKE_CXX_COMPILER=clang++ -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl ..
-
Build:
make
-
Run:
./strix
-
Install Dependencies:
sudo apt-get update sudo apt-get install cmake g++ libssl-dev
-
Generate Build Files:
mkdir build && cd build cmake -G "Unix Makefiles" -DCMAKE_CXX_COMPILER=g++ ..
-
Build:
make
-
Run:
./strix
-
Install Dependencies:
- Install CMake and add it to your PATH.
- Install OpenSSL via vcpkg:
git clone https://github.com/Microsoft/vcpkg.git cd vcpkg .\bootstrap-vcpkg.bat .\vcpkg integrate install .\vcpkg install openssl:x64-windows
- Install Visual Studio 2022 with C++ Desktop Development workload, or MinGW-w64.
-
Generate Build Files:
- Using Visual Studio:
mkdir build && cd build cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_TOOLCHAIN_FILE=[path_to_vcpkg]/scripts/buildsystems/vcpkg.cmake ..
- Using MinGW:
mkdir build && cd build cmake -G "MinGW Makefiles" -DCMAKE_CXX_COMPILER=g++ ..
- Using Visual Studio:
-
Build:
- Visual Studio: Open
strix.sln
in the build directory and build thestrix
target. - MinGW:
mingw32-make
- Visual Studio: Open
-
Run:
- Visual Studio: Run from the debugger or
build/Debug/strix.exe
. - MinGW:
.\strix.exe
- Visual Studio: Run from the debugger or
To enable HTTPS, generate a self-signed certificate:
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 -nodes
Update your Config
in main.cpp
with paths to cert.pem
and key.pem
.
- Default server runs on
http://127.0.0.1:8080/
(orhttps
if configured). - Customize
main.cpp
to add routes or handlers:server->addRoute("", "/hello", Strix::Request::Method::GET, std::make_unique<Strix::StaticFileHandler>("./html"));
- Segmentation Fault: Run with a debugger (e.g.,
lldb ./strix
on macOS/Linux, Visual Studio Debugger on Windows) and check the backtrace (bt
). - OpenSSL Not Found: Ensure
OPENSSL_ROOT_DIR
is set correctly in CMake if it’s in a non-standard location. - Compiler Errors: Verify C++23 support with your compiler (
g++ --version
,clang++ --version
, or VS settings).
- Cross-Platform Adjustments: The code already uses
#ifdef _WIN32
for socket handling (e.g.,winsock2.h
vs. POSIX sockets), so it’s cross-platform. - C++23: Specified C++23 explicitly since your code uses concepts (
Loggable
,RequestHandleable
). - OpenSSL: Provided platform-specific installation instructions.
- Build Systems: Covered Unix Makefiles (macOS/Linux), Visual Studio, and MinGW for Windows.