### Quick Start: Deploy PHP 8.5 Application with Docker Source: https://context7.com/freeunitorg/freeunit/llms.txt An end-to-end example demonstrating the deployment of a PHP 8.5 application using Docker. It covers starting FreeUnit, configuring the application via the control API, and testing the deployment. ```bash # 1. Start FreeUnit with PHP 8.5 support mkdir -p /tmp/unit-ctl /www/myapp echo '' > /www/myapp/index.php docker run -d \ --name freeunit \ --mount type=bind,src=/tmp/unit-ctl,dst=/var/run \ --mount type=bind,src=/www,dst=/www \ --network host \ ghcr.io/freeunitorg/freeunit:latest-php8.5 # 2. Wait for the control socket to appear, then configure in one PUT sleep 2 curl -X PUT \ --unix-socket /tmp/unit-ctl/control.unit.sock \ -H "Content-Type: application/json" \ -d '{ "listeners": { "127.0.0.1:8080": { "pass": "applications/myapp" } }, "applications": { "myapp": { "type": "php", "root": "/www/myapp/", "index": "index.php" } } }' http://localhost/config # {"success": "Reconfiguration done."} # 3. Test curl 127.0.0.1:8080 # Hello from FreeUnit 8.5.0! # 4. Verify status curl --unix-socket /tmp/unit-ctl/control.unit.sock http://localhost/status # {"modules":{"php":{"version":"8.5.0",...}},"connections":{...},"requests":{"total":1},...} ``` -------------------------------- ### Install FreeUnit Core Source: https://github.com/freeunitorg/freeunit/blob/master/pkg/community/REMI.md Install the FreeUnit core server package from the official FreeUnit repository. ```bash dnf install freeunit ``` -------------------------------- ### Install GNU parallel Source: https://github.com/freeunitorg/freeunit/blob/master/pkg/docker/README.md Install GNU parallel, which is optional but recommended for using the `-j N` option for parallel builds. ```bash sudo apt-get install -y parallel ``` -------------------------------- ### Application Management Source: https://context7.com/freeunitorg/freeunit/llms.txt Examples for creating and retrieving application configurations. ```APIDOC ## Create a PHP 8.5 application PUT /config/applications/wordpress ### Description Configures a PHP application with specified settings. ### Method PUT ### Endpoint /config/applications/wordpress ### Request Body - **type** (string) - Required - The type of application (e.g., "php"). - **root** (string) - Required - The root directory for the application. - **index** (string) - Required - The index file for the application. - **user** (string) - Required - The user to run the application as. - **group** (string) - Required - The group to run the application as. - **options** (object) - Optional - Application-specific options. - **file** (string) - Optional - Path to the configuration file. - **admin** (object) - Optional - Admin settings. - **memory_limit** (string) - Optional - Memory limit for the application. ### Request Example ```json { "type": "php", "root": "/www/wordpress/", "index": "index.php", "user": "www-data", "group": "www-data", "options": { "file": "/etc/php.ini", "admin": { "memory_limit": "256M" } } } ``` ### Response #### Success Response (200) - **success** (string) - Indicates successful reconfiguration. ### Response Example ```json {"success": "Reconfiguration done."} ``` ## Create a WebAssembly WASI Component application PUT /config/applications/wasiapp ### Description Configures a WebAssembly WASI Component application. ### Method PUT ### Endpoint /config/applications/wasiapp ### Request Body - **type** (string) - Required - The type of application ("wasm-wasi-component"). - **component** (string) - Required - Path to the WASM component file. ### Request Example ```json { "type": "wasm-wasi-component", "component": "/www/wasmapp-proxy-component.wasm" } ``` ### Response #### Success Response (200) - **success** (string) - Indicates successful reconfiguration. ### Response Example ```json {"success": "Reconfiguration done."} ``` ## GET a single application GET /config/applications/{appName} ### Description Retrieves the configuration of a specific application. ### Method GET ### Endpoint /config/applications/{appName} ### Response #### Success Response (200) - **type** (string) - The type of the application. - **processes** (integer) - The number of worker processes. - **module** (string) - The application module. ### Response Example ```json {"type":"python 3.11","processes":16,"module":"blog.wsgi",...} ``` ``` -------------------------------- ### PHP Application Configuration Example Source: https://github.com/freeunitorg/freeunit/blob/master/TODO.md Example of a PHP application configuration object including `async`, `entrypoint`, and `shutdown_timeout` settings. The `shutdown_timeout` option configures the grace period before forcefully terminating a worker during shutdown. ```json { "type": "php", "async": true, "entrypoint": "server.php", "shutdown_timeout": 30 } ``` -------------------------------- ### Verify Docker installation Source: https://github.com/freeunitorg/freeunit/blob/master/pkg/docker/README.md Verify that Docker and Docker Buildx are installed correctly by checking their versions. ```bash docker version docker buildx version ``` -------------------------------- ### Install Docker Engine on Ubuntu Source: https://github.com/freeunitorg/freeunit/blob/master/pkg/docker/README.md Install the Docker Engine, CLI, containerd, buildx plugin, and compose plugin on Ubuntu 24.04 LTS. This includes removing old versions and setting up the official Docker apt repository. ```bash # Remove any old Docker packages sudo apt-get remove -y docker.io docker-doc docker-compose \ docker-compose-v2 podman-docker containerd runc 2>/dev/null || true # Add Docker's official apt repository sudo apt-get update sudo apt-get install -y ca-certificates curl sudo install -m 0755 -d /etc/apt/keyrings sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg \ -o /etc/apt/keyrings/docker.asc sudo chmod a+r /etc/apt/keyrings/docker.asc echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] \ https://download.docker.com/linux/ubuntu \ $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null sudo apt-get update sudo apt-get install -y docker-ce docker-ce-cli containerd.io \ docker-buildx-plugin docker-compose-plugin # Allow running docker without sudo (re-login required) sudo usermod -aG docker "$USER" ``` -------------------------------- ### Get Status Applications App Processes Starting Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the starting processes app status number. ```APIDOC ## GET /status/applications/{appName}/processes/starting ### Description Retrieve the starting processes app status number. ### Method GET ### Endpoint /status/applications/{appName}/processes/starting #### Path Parameters - **appName** (string) - Required - The name of the application. ``` -------------------------------- ### Install GNU Core Utilities on macOS Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/README.md On Macintosh systems, install necessary GNU core utilities using Homebrew before building unitctl. ```shell $ brew install make gnu-sed grep gawk maven ``` -------------------------------- ### Install Remi PHP Module Source: https://github.com/freeunitorg/freeunit/blob/master/pkg/community/REMI.md Install a specific PHP module from Remi's repository, ensuring to enable the corresponding per-PHP repository. Adjust `phpXX` to match your desired PHP version. ```bash # Install PHP module from Remi — enable the matching per-PHP repo dnf install --enablerepo=remi-php84 unit-php # adjust phpXX to match your PHP version ``` -------------------------------- ### Get Settings Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the settings object. ```APIDOC ## GET /config/settings ### Description Retrieve the settings object. ### Method GET ### Endpoint /config/settings ``` -------------------------------- ### Configure FreeUnit Repository Source: https://github.com/freeunitorg/freeunit/blob/master/tools/README.md Use `setup-unit repo-config` to configure your package manager with the FreeUnit repository for subsequent installations. ```shell setup-unit repo-config ``` -------------------------------- ### Build FreeUnit from Source Source: https://context7.com/freeunitorg/freeunit/llms.txt Clones the FreeUnit repository, configures the build with OpenSSL and OpenTelemetry support, and installs the server binaries. ```bash $ git clone https://github.com/freeunitorg/freeunit $ cd freeunit $ ./configure --openssl --otel # enable TLS and OpenTelemetry support $ make $ sudo make unitd-install ``` -------------------------------- ### Install and Run FreeUnit Docker Image Source: https://context7.com/freeunitorg/freeunit/llms.txt Pulls the minimal FreeUnit Docker image and runs it, serving a local directory. Shows how to mount control socket and web content directories. Lists available language-specific image tags. ```console # Pull the minimal image and serve a local directory $ docker pull ghcr.io/freeunitorg/freeunit:latest-minimal $ mkdir /tmp/unit-control $ docker run -d \ --mount type=bind,src=/tmp/unit-control,dst=/var/run \ --mount type=bind,src=$(pwd),dst=/www \ --network host \ ghcr.io/freeunitorg/freeunit:latest-minimal # Available language variants: # ghcr.io/freeunitorg/freeunit:latest-php8.5 # ghcr.io/freeunitorg/freeunit:latest-php8.4 # ghcr.io/freeunitorg/freeunit:latest-php8.3 # ghcr.io/freeunitorg/freeunit:latest-python3.14 # ghcr.io/freeunitorg/freeunit:latest-python3.13 # ghcr.io/freeunitorg/freeunit:latest-node24 # ghcr.io/freeunitorg/freeunit:latest-node22 # ghcr.io/freeunitorg/freeunit:latest-go1.26 # ghcr.io/freeunitorg/freeunit:latest-ruby3.4 # ghcr.io/freeunitorg/freeunit:latest-wasm ``` -------------------------------- ### Get Applications Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the applications object. ```APIDOC ## GET /config/applications ### Description Retrieve the applications object. ### Method GET ### Endpoint /config/applications ``` -------------------------------- ### Build FreeUnit from Source Source: https://github.com/freeunitorg/freeunit/blob/master/README.md Clones the FreeUnit repository, configures the build with OpenSSL and OpenTelemetry support, compiles, and installs the server. ```console $ git clone https://github.com/freeunitorg/freeunit $ cd freeunit $ ./configure --openssl --otel $ make $ sudo make unitd-install ``` -------------------------------- ### Get Listeners Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve all the listeners. ```APIDOC ## GET /config/listeners ### Description Retrieve all the listeners. ### Method GET ### Endpoint /config/listeners ``` -------------------------------- ### Get Application Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves a specific application configuration by its name. ```APIDOC ## GET /config/applications/{appName} ### Description Retrieve an application object. ### Method GET ### Endpoint /config/applications/{appName} ### Parameters #### Path Parameters - **appName** (string) - Required - The name of the application. ``` -------------------------------- ### Get Single Application Configuration Source: https://context7.com/freeunitorg/freeunit/llms.txt Retrieve the configuration details for a specific application by its name. ```bash curl --unix-socket /var/run/control.unit.sock \ http://localhost/config/applications/pythonapp ``` -------------------------------- ### Install unitctl CLI Source: https://github.com/freeunitorg/freeunit/blob/master/README.md Extracts the unitctl command-line tool from a tarball and suggests moving it to a system-wide binary directory. ```console $ tar xzvf unitctl-master-x86_64-unknown-linux-gnu.tar.gz # mv unitctl /usr/local/bin/ ``` -------------------------------- ### Get Config Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the config object. ```APIDIDOC ## GET /config ### Description Retrieve the config. ### Method GET ### Endpoint /config ``` -------------------------------- ### Get Routes Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the routes entity. ```APIDOC ## GET /config/routes ### Description Retrieve the routes entity. ### Method GET ### Endpoint /config/routes ``` -------------------------------- ### Example Unit Configuration Endpoint Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Illustrates how Unit's API exposes configuration as addressable endpoints. Object options are addressable by name, and array items by index. ```json { "*:8080": { "pass": "applications/wp_emea_dev" } } ``` -------------------------------- ### Get Settings HTTP Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the http object from settings. ```APIDOC ## GET /config/settings/http ### Description Retrieve the http object from settings. ### Method GET ### Endpoint /config/settings/http ``` -------------------------------- ### Start New Unit Process via Docker Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/README.md Launches a new Unit container using a specified image. Provides arguments for control API access (socket or TCP), application path mounting, and the image tag. The `-r` flag can be used for read-only application volume mounts. ```bash $ unitctl instances new /tmp/2 $(pwd) 'unit:wasm' Pulling and starting a container from unit:wasm Will mount /tmp/2 to /var/run for socket access Will mount /home/user/repositories/nginx/unit/tools/unitctl to /www for application access Note: Container will be on host network ``` -------------------------------- ### PHP Hello World Application Source: https://github.com/freeunitorg/freeunit/blob/master/README.md A simple PHP script that outputs a greeting. This is used to demonstrate a basic application setup with FreeUnit. ```php ``` -------------------------------- ### Build Python Module (Native) Source: https://github.com/freeunitorg/freeunit/blob/master/test/README.md Build the Python language module for FreeUnit on the host system. Requires root privileges for installation. ```bash sudo ./configure python --config=python3-config sudo make python3 ``` -------------------------------- ### Get Settings HTTP Static Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the static object from http settings. ```APIDOC ## GET /config/settings/http/static ### Description Retrieve the static object from http settings. ### Method GET ### Endpoint /config/settings/http/static ``` -------------------------------- ### Create Initial FreeUnit Welcome Page Configuration Source: https://github.com/freeunitorg/freeunit/blob/master/tools/README.md Use `setup-unit welcome` to create an initial configuration that serves a welcome web page with FreeUnit. ```shell setup-unit welcome ``` -------------------------------- ### Build FreeUnit Docker images locally Source: https://github.com/freeunitorg/freeunit/blob/master/pkg/docker/README.md Navigate to the Docker package directory to start building images. The `build-local.sh` script supports various options for building specific variants, in parallel, for different platforms, or performing a dry-run. ```bash cd pkg/docker ``` -------------------------------- ### Restart FreeUnit Service Source: https://github.com/freeunitorg/freeunit/blob/master/pkg/community/REMI.md Restart the FreeUnit service to load newly installed modules. ```bash systemctl restart unit ``` -------------------------------- ### Get Application Process Status Source: https://context7.com/freeunitorg/freeunit/llms.txt Fetches the status of processes for a specific application. This provides insights into running, starting, and idle processes. ```bash # Get processes for a specific application curl --unix-socket /var/run/control.unit.sock \ http://localhost/status/applications/wp/processes # { "running": 9, "starting": 1, "idle": 0 } ``` -------------------------------- ### Apply FreeUnit Configuration from File Source: https://github.com/freeunitorg/freeunit/blob/master/tools/README.md Load and apply FreeUnit configuration from a JSON file using stdin. ```shell unitc /config < unitconf.json ``` -------------------------------- ### CertificatesApi: Get Certificate Bundle Chain Validity Since Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the starting time of certificate validity within a bundle's chain. ```APIDOC ## GET /certificates/{bundleName}/chain/{arrayIndex}/validity/since ### Description Retrieve the starting time of certificate validity. ### Method GET ### Endpoint /certificates/{bundleName}/chain/{arrayIndex}/validity/since ### Parameters #### Path Parameters - **bundleName** (string) - Required - The name of the certificate bundle. - **arrayIndex** (integer) - Required - The index of the certificate in the chain. ``` -------------------------------- ### Build FreeUnit with Test Support (Native) Source: https://github.com/freeunitorg/freeunit/blob/master/test/README.md Configure and build the FreeUnit project directly on the host system with test support enabled. This is the first step for native testing. ```bash ./configure --openssl --njs --zlib --zstd --brotli --otel --tests make -j$(nproc) ``` -------------------------------- ### Get All Stored Certificate Bundles Source: https://context7.com/freeunitorg/freeunit/llms.txt Fetch a list of all certificate bundles currently stored in the Unit certificate store. ```bash curl --unix-socket /var/run/control.unit.sock http://localhost/certificates ``` -------------------------------- ### Build FreeUnit from Source Source: https://github.com/freeunitorg/freeunit/blob/master/CONTRIBUTING.md Clone the repository and build the project locally. Ensure you have the necessary dependencies like OpenSSL and OpenTelemetry. ```bash git clone https://github.com/freeunitorg/freeunit cd freeunit ./configure --openssl --otel make ``` -------------------------------- ### Conventional Commit Message Examples Source: https://github.com/freeunitorg/freeunit/blob/master/CONTRIBUTING.md Examples of commit messages following the conventional commits format for various types of changes. ```git fix: correct PHP 8.5 SAPI initialization feat: add otel trace_id to access log docs: update installation instructions ``` -------------------------------- ### Get Full Status Snapshot Source: https://context7.com/freeunitorg/freeunit/llms.txt Retrieve a comprehensive snapshot of the Unit server's runtime status, including loaded modules, connection statistics, request counts, and per-application process information. ```bash curl --unix-socket /var/run/control.unit.sock http://localhost/status ``` -------------------------------- ### Get Listen Threads Setting Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the current value of the listen_threads option from the system settings. ```APIDOC ## GET /config/settings/listen_threads ### Description Retrieve the listen_threads option from settings. ### Method GET ### Endpoint /config/settings/listen_threads ``` -------------------------------- ### Pull Docker Images for PHP 8.5 and PHP 8.4 Source: https://github.com/freeunitorg/freeunit/blob/master/README.md Use these commands to pull the latest Docker images for FreeUnit with specific PHP versions. Ensure Docker is installed and running. ```console $ docker pull ghcr.io/freeunitorg/freeunit:latest-php8.5 ``` ```console $ docker pull ghcr.io/freeunitorg/freeunit:latest-php8.4 ``` -------------------------------- ### Get Status Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the status object. ```APIDOC ## GET /status ### Description Retrieve the status object. ### Method GET ### Endpoint /status ``` -------------------------------- ### Import Configuration from Directory Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/README.md Parses configuration files, certificates, and NJS modules from a specified directory and converts them into a payload to reconfigure a Unit daemon. ```bash $ unitctl import /opt/unit/config Imported /opt/unit/config/certificates/snake.pem -> /certificates/snake.pem Imported /opt/unit/config/hello.js -> /js_modules/hello.js Imported /opt/unit/config/put.json -> /config Imported 3 files ``` -------------------------------- ### Retrieve Full Configuration via Control API Source: https://context7.com/freeunitorg/freeunit/llms.txt Uses curl to send a GET request to the /config endpoint via the Unix domain socket to retrieve the entire running configuration. Shows expected JSON output structure. ```bash # GET — retrieve the full running configuration curl --unix-socket /var/run/control.unit.sock http://localhost/config # Expected output: # { # "access_log": "/var/log/unit/access.log", # "applications": { ... }, # "listeners": { ... }, # "routes": { ... }, # "settings": { ... } # } ``` -------------------------------- ### List configured applications Source: https://context7.com/freeunitorg/freeunit/llms.txt Lists all applications configured in FreeUnit. The output shows the application name and its configuration details, including type and root directory or module. ```bash $ unitctl apps list ``` ```json { "wordpress": { "type": "php", "root": "/www/wordpress/" }, "api": { "type": "python 3.14", "module": "api.wsgi" } } ``` -------------------------------- ### Show Help for Docker Test Runner Source: https://github.com/freeunitorg/freeunit/blob/master/test/README.md Display the help message for the `run-local.sh` script, which outlines all available options and usage instructions for the Docker-based test runner. ```bash ./test/run-local.sh -h ``` -------------------------------- ### Publish Source Tarball and Checksum Source: https://github.com/freeunitorg/freeunit/blob/master/RELEASE-PROCESS.md Create a distribution tarball and checksum, then transfer them to the download server. Ensure you are in the 'pkg' directory. ```bash cd pkg make dist rsync -tv unit-X.Y.Z.tar.* dev:/data/www/freeunit.org/download/ ``` -------------------------------- ### Get Listener Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve a listener object by name. ```APIDOC ## GET /config/listeners/{listenerName} ### Description Retrieve a listener object. ### Method GET ### Endpoint /config/listeners/{listenerName} ### Parameters #### Path Parameters - **listenerName** (string) - Required - The name of the listener ``` -------------------------------- ### CertificatesApi: Get Certificates Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the certificates object. ```APIDOC ## GET /certificates ### Description Retrieve the certificates object. ### Method GET ### Endpoint /certificates ``` -------------------------------- ### Get All Listeners Source: https://context7.com/freeunitorg/freeunit/llms.txt Retrieve a JSON object containing all configured listeners. This is useful for auditing or understanding the current network configuration. ```bash curl --unix-socket /var/run/control.unit.sock http://localhost/config/listeners ``` -------------------------------- ### unitctl CLI Help and Usage Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/README.md Displays the general usage and available commands for the unitctl CLI. Use this to understand the CLI's capabilities and options. ```shell CLI interface to the FreeUnit Control API Usage: unitctl [OPTIONS] Commands: instances List all running Unit processes edit Open current Unit configuration in editor import Import configuration from a directory execute Sends raw JSON payload to Unit status Get the current status of Unit listeners List active listeners apps List all configured Unit applications export Export the current configuration of Unit help Print this message or the help of the given subcommand(s) Options: -s, --control-socket-address Path (unix:/var/run/unit/control.sock), tcp address with port (127.0.0.1:80), or URL. This flag can be specified multiple times. -w, --wait-timeout-seconds Number of seconds to wait for control socket to become available -t, --wait-max-tries Number of times to try to access control socket when waiting [default: 3] -h, --help Print help -V, --version Print version ``` -------------------------------- ### Get FreeUnit Configuration Source: https://github.com/freeunitorg/freeunit/blob/master/tools/README.md Retrieve the current FreeUnit configuration from the `/config` endpoint. Assumes local control socket detection. ```shell unitc /config ``` -------------------------------- ### Get Status Requests Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the requests status object. ```APIDOC ## GET /status/requests ### Description Retrieve the requests status object. ### Method GET ### Endpoint /status/requests ``` -------------------------------- ### Get Status Modules Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the modules status object. ```APIDOC ## GET /status/modules ### Description Retrieve the modules status object. ### Method GET ### Endpoint /status/modules ``` -------------------------------- ### List Running Unit Instances with unitctl Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/README.md Use the 'instances' command to list all running Unit processes. If no socket path is provided, unitctl attempts to detect it from running instances. Provides details like PID, version, executable path, API control socket, child process IDs, runtime flags, and configure options. ```shell $ unitctl instances No socket path provided - attempting to detect from running instance unitd instance [pid: 79489, version: 1.32.0]: Executable: /opt/unit/sbin/unitd API control unix socket: unix:/opt/unit/control.unit.sock Child processes ids: 79489, 79489 Runtime flags: --no-daemon Configure options: --prefix=/opt/unit --user=elijah --group=elijah --openssl ``` -------------------------------- ### Get Status Connections Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the connections status object. ```APIDOC ## GET /status/connections ### Description Retrieve the connections status object. ### Method GET ### Endpoint /status/connections ``` -------------------------------- ### Get Status Applications Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the applications status object. ```APIDOC ## GET /status/applications ### Description Retrieve the applications status object. ### Method GET ### Endpoint /status/applications ``` -------------------------------- ### Build unitctl using Makefile Targets Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/README.md Use the provided Makefile to build the unitctl CLI. 'list-targets' shows available platforms, and specific targets (e.g., 'x86_64-unknown-linux-gnu') can be used to build for a particular platform. 'make all' builds all available binary targets. ```shell $ make list-targets x86_64-unknown-linux-gnu $ make x86_64-unknown-linux-gnu ▶ building unitctl with flags [--quiet --release --bin unitctl --target x86_64-unknown-linux-gnu] $ file ./target/x86_64-unknown-linux-gnu/release/unitctl ./target/x86_64-unknown-linux-gnu/release/unitctl: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=ef4b094ffd549b39a8cb27a7ba2cc0dbad87a3bc, for GNU/Linux 4.4.0, with debug_info, not stripped ``` -------------------------------- ### Get Listener Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves a specific listener object by its name. ```APIDOC ## GET /config/listeners/{listenerName} ### Description Retrieve a listener object. ### Method GET ### Endpoint /config/listeners/{listenerName} ### Parameters #### Path Parameters - **listenerName** (string) - Required - The name of the listener to retrieve. ``` -------------------------------- ### Build PHP Module (Native) Source: https://github.com/freeunitorg/freeunit/blob/master/test/README.md Build the PHP language module for FreeUnit on the host system. ```bash ./configure php make php ``` -------------------------------- ### Build Ruby Module (Native) Source: https://github.com/freeunitorg/freeunit/blob/master/test/README.md Build the Ruby language module for FreeUnit on the host system. ```bash ./configure ruby make ruby ``` -------------------------------- ### Get Status Requests Total Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the total requests number. ```APIDOC ## GET /status/requests/total ### Description Retrieve the total requests number. ### Method GET ### Endpoint /status/requests/total ``` -------------------------------- ### Get Status Modules Lang Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the language module object. ```APIDOC ## GET /status/modules/{langMod} ### Description Retrieve the language module object. ### Method GET ### Endpoint /status/modules/{langMod} #### Path Parameters - **langMod** (string) - Required - The language module identifier. ``` -------------------------------- ### Configure Routes with Match Patterns and Actions Source: https://context7.com/freeunitorg/freeunit/llms.txt Define a named route with multiple rules. Rules can include host, URI, method, header, cookie, and source address matching, along with actions like passing to an application, sharing static files, or returning a redirect. ```bash curl -X PUT --unix-socket /var/run/control.unit.sock \ -H "Content-Type: application/json" \ -d '[ { "match": { "arguments": { "mode": "strict", "fullAccess": "true" }, "uri": "~^/data/www/.*\.php(/.*)?$" }, "action": { "pass": "applications/${host}_php_handler" } }, { "match": { "headers": [{ "User-Agent": "curl*" }], "source": ["!192.168.1.1", "!10.1.1.0/16", "192.168.1.0/24", "2001:0db8::/32"] }, "action": { "share": "/www/data$uri" } }, { "action": { "return": 301, "location": "https://www.example.com" } } ]' http://localhost/config/routes/myapp ``` -------------------------------- ### Get Status Connections Idle Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the idle connections number. ```APIDOC ## GET /status/connections/idle ### Description Retrieve the idle connections number. ### Method GET ### Endpoint /status/connections/idle ``` -------------------------------- ### Prepare Seed Corpora Directories (Shell) Source: https://github.com/freeunitorg/freeunit/blob/master/fuzzing/README.md Create directories to store seed corpora for various fuzzers. These directories are used to initialize the fuzzing process with initial test cases. ```shell $ mkdir -p build/fuzz_basic_seed $ mkdir -p build/fuzz_http_controller_seed $ mkdir -p build/fuzz_http_h1p_seed $ mkdir -p build/fuzz_http_h1p_peer_seed $ mkdir -p build/fuzz_json_seed ``` -------------------------------- ### Create WebAssembly WASI Component Application Source: https://context7.com/freeunitorg/freeunit/llms.txt Configure a WebAssembly WASI Component application by specifying its type and the path to the component file. ```bash curl -X PUT --unix-socket /var/run/control.unit.sock \ -H "Content-Type: application/json" \ -d '{ "type": "wasm-wasi-component", "component": "/www/wasmapp-proxy-component.wasm" }' http://localhost/config/applications/wasiapp ``` -------------------------------- ### Get Status Connections Closed Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the closed connections number. ```APIDOC ## GET /status/connections/closed ### Description Retrieve the closed connections number. ### Method GET ### Endpoint /status/connections/closed ``` -------------------------------- ### Get Status Connections Active Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the active connections number. ```APIDOC ## GET /status/connections/active ### Description Retrieve the active connections number. ### Method GET ### Endpoint /status/connections/active ``` -------------------------------- ### Get Status Connections Accepted Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the accepted connections number. ```APIDOC ## GET /status/connections/accepted ### Description Retrieve the accepted connections number. ### Method GET ### Endpoint /status/connections/accepted ``` -------------------------------- ### Configure FreeUnit Application Source: https://github.com/freeunitorg/freeunit/blob/master/README.md Uses curl to send a PUT request to the FreeUnit control socket to configure a new application named 'helloworld'. ```console # curl -X PUT --data-binary @config.json \ --unix-socket /var/run/control.unit.sock \ http://localhost/config/applications ``` -------------------------------- ### Get Status Applications App Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the app status object. ```APIDOC ## GET /status/applications/{appName} ### Description Retrieve the app status object. ### Method GET ### Endpoint /status/applications/{appName} #### Path Parameters - **appName** (string) - Required - The name of the application. ``` -------------------------------- ### List Running FreeUnit Instances Source: https://context7.com/freeunitorg/freeunit/llms.txt Uses the `unitctl` CLI to detect and list all running FreeUnit instances on the host. It displays PIDs, versions, socket paths, and configuration details. ```console # Detect and list all running FreeUnit processes on the host $ unitctl instances unitd instance [pid: 79489, version: 1.35.3]: Executable: /opt/unit/sbin/unitd API control unix socket: unix:/opt/unit/control.unit.sock Child processes ids: 79490, 79491 Runtime flags: --no-daemon Configure options: --prefix=/opt/unit --user=www --group=www --openssl ``` -------------------------------- ### Get Listener Pass Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the pass option for a specific listener. ```APIDOC ## GET /config/listeners/{listenerName}/pass ### Description Retrieve the pass option in a listener. ### Method GET ### Endpoint /config/listeners/{listenerName}/pass ### Parameters #### Path Parameters - **listenerName** (string) - Required - The name of the listener. ``` -------------------------------- ### Launch a new FreeUnit container Source: https://context7.com/freeunitorg/freeunit/llms.txt Launches a new FreeUnit container, automatically mounting the socket directory and application directory. Ensure the FreeUnit container image supports the desired runtime (e.g., PHP 8.5). ```bash $ unitctl instances new /tmp/unit-sock $(pwd) 'ghcr.io/freeunitorg/freeunit:latest-php8.5' ``` -------------------------------- ### Get Listener Backlog Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the backlog option for a specific listener. ```APIDOC ## GET /config/listeners/{listenerName}/backlog ### Description Retrieve the backlog option in a listener. ### Method GET ### Endpoint /config/listeners/{listenerName}/backlog ### Parameters #### Path Parameters - **listenerName** (string) - Required - The name of the listener. ``` -------------------------------- ### Get Telemetry Settings Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the telemetry object from the system settings. ```APIDOC ## GET /config/settings/telemetry ### Description Retrieve the `telemetry` object from settings. ### Method GET ### Endpoint /config/settings/telemetry ``` -------------------------------- ### Edit FreeUnit Configuration Interactively Source: https://github.com/freeunitorg/freeunit/blob/master/tools/README.md Open a specified URI in the default editor for interactive configuration editing. Requires jq. ```shell unitc edit /config ``` -------------------------------- ### Get Listener TLS Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the TLS object for a specific listener. ```APIDOC ## GET /config/listeners/{listenerName}/tls ### Description Retrieve the tls object in a listener. ### Method GET ### Endpoint /config/listeners/{listenerName}/tls ### Parameters #### Path Parameters - **listenerName** (string) - Required - The name of the listener ``` -------------------------------- ### Run Tests and Save Logs (Native) Source: https://github.com/freeunitorg/freeunit/blob/master/test/README.md Execute tests on the host system and automatically save the logs after execution. This is helpful for post-mortem analysis of test runs. ```bash sudo pytest-3 --print-log --save-log test/ ``` -------------------------------- ### Get Listener Pass Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the pass option for a specific listener. ```APIDOC ## GET /config/listeners/{listenerName}/pass ### Description Retrieve the pass option in a listener. ### Method GET ### Endpoint /config/listeners/{listenerName}/pass ### Parameters #### Path Parameters - **listenerName** (string) - Required - The name of the listener ``` -------------------------------- ### Restart Application via unitctl CLI Source: https://context7.com/freeunitorg/freeunit/llms.txt Use the `unitctl` command-line tool to gracefully restart a specified application. ```bash unitctl apps restart pythonapp ``` -------------------------------- ### Get Listener Forwarded Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the forwarded object for a specific listener. ```APIDOC ## GET /config/listeners/{listenerName}/forwarded ### Description Retrieve the forwarded object in a listener. ### Method GET ### Endpoint /config/listeners/{listenerName}/forwarded ### Parameters #### Path Parameters - **listenerName** (string) - Required - The name of the listener ``` -------------------------------- ### Get Listener Backlog Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the backlog option for a specific listener. ```APIDOC ## GET /config/listeners/{listenerName}/backlog ### Description Retrieve the backlog option in a listener. ### Method GET ### Endpoint /config/listeners/{listenerName}/backlog ### Parameters #### Path Parameters - **listenerName** (string) - Required - The name of the listener ``` -------------------------------- ### Get Access Log Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the current access log configuration. ```APIDOC ## GET /config/access_log ### Description Retrieve the access log. ### Method GET ### Endpoint /config/access_log ``` -------------------------------- ### Add async and entrypoint fields to nxt_php_app_conf_t Source: https://github.com/freeunitorg/freeunit/blob/master/TODO.md Adds `async` and `entrypoint` fields to the `nxt_php_app_conf_t` struct in `src/nxt_application.h`. These fields are required for TrueAsync mode configuration. ```c typedef struct { nxt_conf_value_t *targets; nxt_conf_value_t *options; nxt_bool_t async; /* true when TrueAsync mode requested */ nxt_str_t entrypoint; /* path to the PHP entrypoint script */ } nxt_php_app_conf_t; ``` -------------------------------- ### Get Listener TLS Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the TLS configuration object for a specific listener. ```APIDOC ## GET /config/listeners/{listenerName}/tls ### Description Retrieve the tls object in a listener. ### Method GET ### Endpoint /config/listeners/{listenerName}/tls ### Parameters #### Path Parameters - **listenerName** (string) - Required - The name of the listener. ``` -------------------------------- ### Create Preparatory Git Branch Source: https://github.com/freeunitorg/freeunit/blob/master/RELEASE-PROCESS.md Create a new branch for release preparation. This is the first step before making any changes. ```bash git checkout -b x.y[.z]-prep master ``` -------------------------------- ### Create PHP 8.5 Application Source: https://context7.com/freeunitorg/freeunit/llms.txt Use this command to create a new PHP application. Specify the application type, root directory, index file, user, group, and optional PHP configuration options. ```bash curl -X PUT --unix-socket /var/run/control.unit.sock \ -H "Content-Type: application/json" \ -d '{ "type": "php", "root": "/www/wordpress/", "index": "index.php", "user": "www-data", "group": "www-data", "options": { "file": "/etc/php.ini", "admin": { "memory_limit": "256M" } } }' http://localhost/config/applications/wordpress ``` -------------------------------- ### Get Listener Forwarded Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the forwarded object configuration for a specific listener. ```APIDOC ## GET /config/listeners/{listenerName}/forwarded ### Description Retrieve the forwarded object in a listener. ### Method GET ### Endpoint /config/listeners/{listenerName}/forwarded ### Parameters #### Path Parameters - **listenerName** (string) - Required - The name of the listener. ``` -------------------------------- ### Add Listener Configuration to FreeUnit Source: https://github.com/freeunitorg/freeunit/blob/master/tools/README.md Append a new listener configuration to the FreeUnit configuration using stdin. ```shell echo '{"*:8080": {"pass": "routes"}}' | unitc /config/listeners ``` -------------------------------- ### Get Access Log Path Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the path option for the access log. ```APIDOC ## GET /config/access_log/path ### Description Retrieve the access log path option. ### Method GET ### Endpoint /config/access_log/path ``` -------------------------------- ### Configure Simple Access Log Path Source: https://context7.com/freeunitorg/freeunit/llms.txt Sets the access log to a simple file path. All requests will be logged to this specified file. ```bash # Set a simple access log path curl -X PUT --unix-socket /var/run/control.unit.sock \ -H "Content-Type: application/json" \ -d '"/var/log/unit/access.log"' \ http://localhost/config/access_log # {"success": "Reconfiguration done."} ``` -------------------------------- ### Get Access Log Format Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the format option for the access log. ```APIDOC ## GET /config/access_log/format ### Description Retrieve the access log format option. ### Method GET ### Endpoint /config/access_log/format ``` -------------------------------- ### Run Tests with Restart Mode (Native) Source: https://github.com/freeunitorg/freeunit/blob/master/test/README.md Execute tests on the host system with the restart mode enabled. Unit restarts after each test, which is slower but helps catch state leakage issues. ```bash sudo pytest-3 --print-log --restart test/ ``` -------------------------------- ### Run FreeUnit Docker Container Source: https://github.com/freeunitorg/freeunit/blob/master/README.md Pulls the latest minimal FreeUnit Docker image and runs it, mounting a local directory for control sockets and web content. ```console $ docker pull ghcr.io/freeunitorg/freeunit:latest-minimal $ mkdir /tmp/unit-control $ docker run -d \ --mount type=bind,src=/tmp/unit-control,dst=/var/run \ --mount type=bind,src=.,dst=/www \ --network host \ ghcr.io/freeunitorg/freeunit:latest-minimal ``` -------------------------------- ### Test FreeUnit PHP Application Source: https://github.com/freeunitorg/freeunit/blob/master/README.md Makes an HTTP request to the configured listener to verify that the 'Hello, PHP on FreeUnit!' message is returned. ```console $ curl 127.0.0.1:8080 ``` -------------------------------- ### Get Status Modules Lang Version Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the language module version object. ```APIDOC ## GET /status/modules/{langMod}/version ### Description Retrieve the language module version object. ### Method GET ### Endpoint /status/modules/{langMod}/version #### Path Parameters - **langMod** (string) - Required - The language module identifier. ``` -------------------------------- ### Configure Global HTTP Settings with Compression Source: https://context7.com/freeunitorg/freeunit/llms.txt Configures global HTTP settings, including various timeouts, maximum body size, server version exposure, route logging, unsafe header discarding, and response compression with multiple encoding types. ```bash # Configure HTTP settings with compression enabled curl -X PUT --unix-socket /var/run/control.unit.sock \ -H "Content-Type: application/json" \ -d '{ "body_read_timeout": 30, "header_read_timeout": 30, "send_timeout": 30, "idle_timeout": 30, "max_body_size": 8388608, "discard_unsafe_fields": true, "server_version": false, "log_route": true, "compression": { "types": ["text/*", "application/json", "application/javascript"], "compressors": [ { "encoding": "gzip", "level": 3, "min_length": 2048 }, { "encoding": "deflate", "min_length": 1024 }, { "encoding": "zstd", "min_length": 0 }, { "encoding": "br" } ] }, "static": { "mime_types": { "text/x-code": [".c", ".h"], "application/wasm": [".wasm"] } } }' http://localhost/config/settings/http # {"success": "Reconfiguration done."} ``` -------------------------------- ### Get Status Modules Lang Lib Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the language module lib object. ```APIDOC ## GET /status/modules/{langMod}/lib ### Description Retrieves the language module lib object. ### Method GET ### Endpoint /status/modules/{langMod}/lib #### Path Parameters - **langMod** (string) - Required - The language module identifier. ``` -------------------------------- ### Get Status Applications App Requests Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the requests app status object. ```APIDOC ## GET /status/applications/{appName}/requests ### Description Retrieve the requests app status object. ### Method GET ### Endpoint /status/applications/{appName}/requests #### Path Parameters - **appName** (string) - Required - The name of the application. ``` -------------------------------- ### List Listener TLS Configuration Commands Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the configured commands for the TLS configuration of a listener. ```APIDOC ## GET /config/listeners/{listenerName}/tls/conf_commands ### Description Retrieve the conf_commands object in a listener. ### Method GET ### Endpoint /config/listeners/{listenerName}/tls/conf_commands ``` -------------------------------- ### Get Status Applications App Processes Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the processes app status object. ```APIDOC ## GET /status/applications/{appName}/processes ### Description Retrieve the processes app status object. ### Method GET ### Endpoint /status/applications/{appName}/processes #### Path Parameters - **appName** (string) - Required - The name of the application. ``` -------------------------------- ### Get Settings HTTP Send Timeout Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the send_timeout option from http settings. ```APIDOC ## GET /config/settings/http/send_timeout ### Description Retrieve the send_timeout option from http settings. ### Method GET ### Endpoint /config/settings/http/send_timeout ``` -------------------------------- ### Get Settings HTTP Idle Timeout Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the idle_timeout option from http settings. ```APIDOC ## GET /config/settings/http/idle_timeout ### Description Retrieve the idle_timeout option from http settings. ### Method GET ### Endpoint /config/settings/http/idle_timeout ``` -------------------------------- ### Create a Node.js Application Source: https://context7.com/freeunitorg/freeunit/llms.txt Define an external Node.js application, specifying the working directory, executable, and user/group. Command-line arguments for the Node.js process can also be provided. ```bash curl -X PUT --unix-socket /var/run/control.unit.sock \ -H "Content-Type: application/json" \ -d '{ "type": "external", "working_directory": "/www/app/node-app/", "executable": "app.js", "user": "www", "group": "www", "arguments": ["--tmp-files", "/tmp/node-cache"] }' http://localhost/config/applications/nodejsapp ``` -------------------------------- ### Get Settings Discard Unsafe Fields Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the discard_unsafe_fields option from http settings. ```APIDOC ## GET /config/settings/http/discard_unsafe_fields ### Description Retrieve the discard_unsafe_fields option from http settings. ### Method GET ### Endpoint /config/settings/http/discard_unsafe_fields ``` -------------------------------- ### Get Listener Forwarded Recursive Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the recursive option within the forwarded configuration of a listener. ```APIDOC ## GET /config/listeners/{listenerName}/forwarded/recursive ### Description Retrieve the recursive option in a listener. ### Method GET ### Endpoint /config/listeners/{listenerName}/forwarded/recursive ### Parameters #### Path Parameters - **listenerName** (string) - Required - The name of the listener. ``` -------------------------------- ### Build Unit for Fuzzing (Shell) Source: https://github.com/freeunitorg/freeunit/blob/master/fuzzing/README.md Configure and build the Unit project for fuzzing. Use the --fuzz flag with the appropriate libFuzzer engine and build with multiple parallel jobs for faster compilation. ```shell $ ./configure --no-regex --no-pcre2 --fuzz=$LIB_FUZZING_ENGINE $ make fuzz -j$(nproc) ``` -------------------------------- ### Get Listener Forwarded Protocol Source: https://github.com/freeunitorg/freeunit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the protocol option within the forwarded configuration of a listener. ```APIDOC ## GET /config/listeners/{listenerName}/forwarded/protocol ### Description Retrieve the protocol option in a listener. ### Method GET ### Endpoint /config/listeners/{listenerName}/forwarded/protocol ### Parameters #### Path Parameters - **listenerName** (string) - Required - The name of the listener. ``` -------------------------------- ### Run Full Test Suite with Docker Source: https://github.com/freeunitorg/freeunit/blob/master/test/README.md Execute the entire FreeUnit test suite within an isolated Docker container. This is the recommended method for local testing. ```bash ./test/run-local.sh ```