Configuration Reference
OxPHP is configured through environment variables, plus one optional file: .oxphpdeny, the path deny rules read from the top of DOCUMENT_ROOT. Every setting has a default, so a zero-configuration deployment works out of the box. oxphp config --check validates a configuration without starting the server, and /config shows what a running server resolved.
Boolean values
Variables marked as boolean accept a fixed set of values, case-insensitive and trimmed:
- truthy:
on,true,1,yes - falsy:
off,false,0,no
Any other non-empty value, such as the typo ture, stops the server at startup with an error naming the variable, so a misspelled flag never flips silently. An unset variable or an empty assignment (FOO=) takes the documented default. That way Compose or Kubernetes substitution like FOO=${FOO}, which produces FOO= when the host variable is missing, does not stop the server.
Server
| Variable | Default | Description |
|---|---|---|
LISTEN_ADDR |
0.0.0.0:80 |
Address and port for the main HTTP server |
DOCUMENT_ROOT |
/var/www/html/public |
Root directory for static files and PHP scripts. A falsy value switches it off: every request goes to ENTRY_FILE and no static files are served. See No Document Root |
ENTRY_FILE |
(unset) | The entry script, which also picks the routing mode: unset or no extension = direct file mapping, *.php = front controller, any other extension = static fallback (SPA), and with WORKER_MODE_ENABLED=true the worker bootstrap. A relative path (.. allowed) is resolved against DOCUMENT_ROOT; an absolute one is used as-is, and is required when DOCUMENT_ROOT is off. See Routing |
WORKER_MODE_ENABLED |
false |
Boolean. Enables persistent worker mode; ENTRY_FILE must point at a .php script. See Worker Mode |
MAX_CONNECTIONS |
10000 |
Maximum concurrent TCP connections; a malformed value is a startup error. Keep it above PHP_WORKERS + QUEUE_CAPACITY + QUEUE_MAX_WAITING, see Keeping headroom for the accept loop |
TOKIO_WORKERS |
CPU / 2 (min 1) | Async I/O threads. 1 = single-threaded, N = fixed count, unset = auto. See Sizing the async runtime |
PHP workers
| Variable | Default | Description |
|---|---|---|
EXECUTOR |
sapi |
PHP executor backend. sapi for PHP execution, stub for benchmarking without PHP |
PHP_WORKERS |
CPU / 2 (min 1) | Worker pool size. N = fixed pool, MIN:MAX = dynamic scaling, 0 = auto. See Static vs dynamic workers |
PHP_WORKERS_IDLE_SECONDS |
30 |
Seconds a dynamic worker stays idle before it is retired. A worker is retired only with nothing in flight, so one holding a request that never ends, such as an open stream, is never retired |
QUEUE_CAPACITY |
Initial workers × 128 | Maximum requests in the PHP queue; a request arriving at a full queue waits for a slot. For a dynamic pool, initial workers = the minimum. 0 = auto |
QUEUE_WAIT_TIMEOUT_MS |
1000 |
The longest a request may wait for a PHP worker before it is rejected with 529. A ceiling the server lowers on its own under overload (see below) |
QUEUE_MAX_WAITING |
Initial workers × 128, capped at MAX_CONNECTIONS / 2 |
Maximum requests parked waiting for a queue slot; past it, requests are rejected at once. Each waiter holds a connection and its buffered body, so size it from your handler latency (Sizing the waiting set). 0 = auto, never below 1 |
QUEUE_MAX_WAITING_BYTES |
67108864 (64 MiB) |
Maximum request-body bytes the parked requests may hold together. A request whose body would pass it is rejected with 529 at once; a request without a body never is. 0 = auto |
QUEUE_WAIT_TIMEOUT_MS is one deadline, stamped when the request arrives, covering both waits: for a slot in the queue, and then in the queue for a worker. Under overload the server shortens it below the configured ceiling, and oxphp_admission_wait_budget_us reports the budget in force (The wait budget). QUEUE_WAIT_TIMEOUT_MS=0 rejects at once when the queue is full, but a request that finds a free slot then waits in the queue with no deadline at all (QUEUE_WAIT_TIMEOUT_MS=0 is not a shorter wait). Lower the ceiling when the application calls this same server over HTTP, or when a load balancer in front times out sooner (When to lower QUEUE_WAIT_TIMEOUT_MS).
How to size the pool, the queue and the waiting set against each other and against MAX_CONNECTIONS, and how the CPU count behind the defaults is detected: Sizing PHP Workers.
Worker Mode
| Variable | Default | Description |
|---|---|---|
WORKER_MAX_MEMORY_MIB |
0 |
Memory in MiB past which a worker is recycled. The worker checks it in its loop, so it is a trigger, not a cap on what PHP can allocate. 0 = no threshold |
Set WORKER_MODE_ENABLED=true and point ENTRY_FILE at your worker bootstrap script (e.g. ENTRY_FILE=worker.php or ENTRY_FILE=../worker.php). Workers then stay alive across requests and keep bootstrap state (autoloaders, database connections) in memory. A worker is recycled when it passes WORKER_MAX_MEMORY_MIB, after three consecutive requests that came apart, or when the application calls Worker::scheduleExit(). Worker Recycling says which requests count toward the three.
SAPI / PHP
| Variable | Default | Description |
|---|---|---|
SUPERGLOBALS_ENABLED |
true |
Boolean. Builds $_SERVER and $_GET before the script runs; set it falsy to skip that work in an application that reads neither. $_POST, $_FILES, $_COOKIE and php://input are unaffected. See SUPERGLOBALS_ENABLED |
Response buffering
| Variable | Default | Description |
|---|---|---|
RESPONSE_BUFFER_BYTES |
1048576 (1 MiB) |
How much of a buffered response's output is held in memory before it moves to a spool file. 0 = default |
RESPONSE_SPOOL_MAX_BYTES |
1073741824 (1 GiB) |
Maximum bytes the spool files of all responses may hold together. A response that would pass it is answered with 503. 0 = default |
A response is buffered unless it streams (Content-Type: text/event-stream or oxphp_stream_flush()). The server holds a buffered response's output until the script ends or calls oxphp_finish_request(), and then for as long as the client takes to read it. The first RESPONSE_BUFFER_BYTES stay in memory. Past that, the output moves to a temporary file and the response is sent from it, so a script that readfile()s a 500 MiB download does not hold 500 MiB of memory for a slow client. Two exceptions: a response eligible for compression (a body of at most 3 MiB) is read back into memory to be compressed, and streamed output is never spooled.
Spool files go to TMPDIR, or /tmp when it is unset or empty. Each file is removed from the directory right after it is created, so it never shows in a listing, and its space is released when the response has been sent, the client has gone, or the server is killed. Where that directory lives decides what the spool costs:
- On the container's writable layer (the default
/tmpof an image) it costs disk. On Kubernetes this counts toward the pod's ephemeral-storage limit, so size that limit forRESPONSE_SPOOL_MAX_BYTES. - On a tmpfs (
docker run --tmpfs /tmp, a KubernetesemptyDirwithmedium: Memory) it costs memory, charged to the container. PointTMPDIRat a disk-backed volume instead. - On a read-only root filesystem no spool file can be created, so every buffered response past
RESPONSE_BUFFER_BYTESis answered with503. Mount a writable volume and pointTMPDIRat it. The server logs a warning at startup when it cannot create a file in the spool directory.
A response that cannot be spooled is answered with 503 Service Unavailable and Retry-After: 5 instead of the script's status, headers and output, and a warning naming the cause is logged. That happens when RESPONSE_SPOOL_MAX_BYTES is reached, or when the file cannot be created or written, for example on a full disk. The script still runs to completion; what it writes after that point is discarded.
Timeouts
| Variable | Default | Description |
|---|---|---|
HEADER_TIMEOUT_SECONDS |
5 |
Maximum seconds to receive HTTP headers after connection (Slowloris protection) |
DRAIN_TIMEOUT_SECONDS |
25 |
Maximum seconds to wait for in-flight connections during graceful shutdown. A request inside a blocking call at the deadline can hold the process past it (see Graceful Shutdown) |
PHP execution time is bounded by PHP's own max_execution_time (and set_time_limit()), not by an OxPHP variable. That bound does not reach a task dispatched with oxphp_async(): bound it with the timeout argument of oxphp_async_await() instead (Async promises). See Timeouts.
Rate limiting
| Variable | Default | Description |
|---|---|---|
RATE_LIMIT |
0 (off) |
Maximum requests per IP per time window. 0 disables rate limiting |
RATE_WINDOW_SECONDS |
60 |
Rate limit window duration in seconds |
Security
| Variable | Default | Description |
|---|---|---|
FRAME_OPTIONS |
SAMEORIGIN |
Clickjacking protection: SAMEORIGIN, DENY or off. Sets both X-Frame-Options and Content-Security-Policy: frame-ancestors; any other value falls back to SAMEORIGIN with a startup warning. See Clickjacking protection |
TRUSTED_PROXIES |
(unset) | Reverse proxies to trust for the client IP, scheme and host: a comma-separated mix of CIDRs, bare IPs and the keywords private and cloudflare (e.g. private,cloudflare). Unset = off. See Trusted Proxies |
PHP_DENY_PATHS |
(unset) | Comma-separated globs for .php files that must never run from a direct URI, directory-index resolution included (e.g. /uploads/**,/cache/**,/admin/legacy.php). Applies in Traditional and SPA modes; Framework and Worker modes ignore it with a startup warning. See PHP Execution Deny-List |
PHP_DENY_FALLBACK |
404 |
The answer to a PHP_DENY_PATHS match or a .oxphpdeny deny rule: a status from 400 to 599 (custom HTML through ERROR_PAGES_DIR), or a /-prefixed path to a PHP script inside DOCUMENT_ROOT. See Path Deny Rules |
SYMLINK_ALLOW_PATHS |
(unset) | Comma-separated absolute paths under which symlinks may point outside DOCUMENT_ROOT. Each must exist; a relative or missing path aborts startup. Unset = no escapes. See Symlink Allow-Paths |
With TRUSTED_PROXIES set, the client IP comes from Forwarded (RFC 7239) or X-Forwarded-For, taking the rightmost address that is not trusted. With cloudflare, a request whose forwarding chain shows it came from a Cloudflare edge takes it from CF-Connecting-IP instead. X-Forwarded-Proto and X-Forwarded-Host set $_SERVER['HTTPS'], REQUEST_SCHEME, SERVER_NAME and SERVER_PORT. The keyword private expands to the RFC 1918 networks, loopback and link-local addresses (IPv4 and IPv6): 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 127.0.0.0/8, 169.254.0.0/16, ::1/128, fc00::/7, fe80::/10.
A direct .php URI is matched against PHP_DENY_PATHS before the disk is touched, so a denied path answers the same whether or not the file exists. A PHP_DENY_FALLBACK script receives OXPHP_DENIED_PATH and OXPHP_DENIED_PATTERN in $_SERVER. It is validated at startup: it must exist, resolve inside DOCUMENT_ROOT, and not match PHP_DENY_PATHS itself. A .oxphpdeny rule may cover it; in worker mode, .oxphpdeny deny rules take a status code only.
Clickjacking protection
In a clickjacking attack, a hostile page embeds your site in an invisible <iframe> and tricks the user into clicking something they cannot see, such as a "delete my account" button, a one-click purchase or an OAuth "authorize" prompt. FRAME_OPTIONS tells the browser who may frame your pages. OxPHP sends both framing headers, the legacy X-Frame-Options and the modern Content-Security-Policy: frame-ancestors (which takes precedence where both are present), so the policy holds in old and new browsers:
FRAME_OPTIONS |
X-Frame-Options |
Content-Security-Policy |
Who may frame your pages |
|---|---|---|---|
SAMEORIGIN (default) |
SAMEORIGIN |
frame-ancestors 'self' |
Only pages on the same origin |
DENY |
DENY |
frame-ancestors 'none' |
No one, not even your own pages |
off |
(not sent) | (not sent) | Anyone (no framing restriction from the server) |
SAMEORIGIN blocks the cross-origin framing that clickjacking relies on and still lets your own pages embed each other, as admin previews, dashboard widgets and same-origin payment components do. Choose DENY when nothing on your site is ever framed, not even by itself. Choose off only when your application sets its own Content-Security-Policy with frame-ancestors.
X-Frame-Options cannot name an allowed origin (ALLOW-FROM was removed from the standard). To let a named third party frame your pages, set FRAME_OPTIONS=off and send your own policy, e.g. header("Content-Security-Policy: frame-ancestors 'self' https://partner.example.com");.
Headers the application sets win. The server's headers are fallbacks, added only when the response has none, and the two framing headers count as one policy, so the server never contradicts the application:
- If your app sets
X-Frame-Options, OxPHP does not addframe-ancestors(a server CSP would override your choice in modern browsers). - If your app sets a
Content-Security-Policythat containsframe-ancestors, OxPHP does not addX-Frame-Options(a stricter one would over-block in legacy browsers that ignore CSP).
X-Content-Type-Options: nosniff, which OxPHP sets on every response, follows the same rule: a value the application sets is kept as is. nosniff is the only value that does anything, so overriding it with anything else turns MIME-sniffing protection off.
TLS
| Variable | Default | Description |
|---|---|---|
TLS_CERT |
(unset) | Path to PEM-encoded TLS certificate. Both TLS_CERT and TLS_KEY must be set to enable TLS |
TLS_KEY |
(unset) | Path to PEM-encoded TLS private key |
TLS_MIN_VERSION |
1.2 |
Minimum TLS version: 1.2 or 1.3. Any other value, non-UTF-8 bytes included, stops the server at startup and fails oxphp config --check, even with TLS off. An empty value is treated as unset |
HTTP/2
| Variable | Default | Description |
|---|---|---|
H2_MAX_CONCURRENT_STREAMS |
PHP_WORKERS_MAX × 4 (min 32) |
Maximum simultaneous open streams per HTTP/2 connection |
H2_MAX_PENDING_RESET |
20 |
Maximum RST_STREAM frames queued before a connection is closed (Rapid Reset protection) |
H2_MAX_HEADER_LIST_BYTES |
65536 |
Maximum total decoded header bytes per request |
H2_KEEPALIVE_INTERVAL_SECS |
20 |
Seconds between HTTP/2 PING frames; 0 disables |
H2_KEEPALIVE_TIMEOUT_SECS |
10 |
Seconds to wait for a PING reply before closing the connection |
Static files
| Variable | Default | Description |
|---|---|---|
STATIC_MAX_AGE |
30d |
Cache-Control: max-age for static files: 30s, 5m, 2h, 30d, 1w, 1y, bare seconds (3600), or off to send no header |
STATIC_REVALIDATE |
off |
Boolean. When truthy, a cached file's modification time is re-checked at most once every 3 seconds per file and stale entries are evicted, so changes show within 3 seconds |
Compression
| Variable | Default | Description |
|---|---|---|
COMPRESSION_ENCODINGS |
br,zstd,gzip |
Codings offered, comma-separated: br (or brotli), zstd, gzip; an unknown name is a startup error. The whole value off (or none) switches compression off, so br,off is an error. See Compression |
COMPRESSION_BROTLI_LEVEL |
5 |
Brotli quality (0 to 11) |
COMPRESSION_ZSTD_LEVEL |
6 |
Zstandard compression level (0 to 19) |
COMPRESSION_GZIP_LEVEL |
6 |
Gzip compression level (0 to 9) |
A coding is offered when COMPRESSION_ENCODINGS lists it and its level is not 0; either one alone withdraws it. A level outside its range, or one that is not a number, aborts startup with an error naming the variable; nothing is clamped. The order you list codings in is ignored: cached static files prefer Brotli, whose cost is paid once, and everything else prefers Zstandard. An empty COMPRESSION_ENCODINGS= restores the default.
Logging
| Variable | Default | Description |
|---|---|---|
LOG_LEVEL |
info |
Log verbosity: trace, debug, info, warn, error |
ACCESS_LOG |
(unset) | Per-request access log: all = every request, error = 4xx/5xx only, unset = off |
A client that closes its connection before the server has answered (a cancelled fetch, a closed tab, a proxy whose read timeout fired) is logged at debug, so the default LOG_LEVEL does not show it. Count these with oxphp_request_cancelled_total{reason="client_abort"}, or raise LOG_LEVEL=debug to see each one. Timeouts the server enforces itself (HEADER_TIMEOUT_SECONDS) are logged at warn, and every other connection failure at error.
The two are independent: LOG_LEVEL=warn with ACCESS_LOG=error reports warnings and errors and logs every 4xx/5xx request. To silence the access log alone, use a RUST_LOG directive naming its target, such as RUST_LOG=warn,access_log=off, with warn standing for the LOG_LEVEL you were running. A parsable RUST_LOG replaces LOG_LEVEL rather than adding to it. See Access logging.
Observability
| Variable | Default | Description |
|---|---|---|
INTERNAL_ADDR |
(unset) | Address for the internal server (/health, /metrics, /config), which is not started when unset. A port-only value (:9090) binds 127.0.0.1; set 0.0.0.0:9090 to expose it off-host |
INTERNAL_ALLOW_IPS |
(unset) | Comma-separated CIDRs/IPs allowed on the internal server. Others get 403 on /metrics, /config and plugin paths, while health probes (/health, /healthz, /readyz, /startupz and their long forms) stay reachable. Loopback is not implicit, so list 127.0.0.1/32; unset = allow all, and a malformed list aborts startup |
ERROR_PAGES_DIR |
(unset) | Directory containing custom error pages named {status}.html (e.g., 404.html, 503.html) |
MAX_QUERY_BODY |
524288 |
Maximum request body size in bytes for internal query endpoints (512 KiB) |
TRACE_CONTEXT |
false |
Boolean. When truthy, reads W3C traceparent/tracestate headers and passes them to PHP in $_SERVER |
OpenTelemetry
| Variable | Default | Description |
|---|---|---|
OTEL_ENABLED |
false |
Boolean. Enables OpenTelemetry span export, and with it TRACE_CONTEXT=true |
OTEL_EXPORTER_OTLP_PROTOCOL |
grpc |
Export protocol: grpc or http/protobuf |
OTEL_EXPORTER_OTLP_ENDPOINT |
http://localhost:4317 (gRPC) or http://localhost:4318 (HTTP) |
OTLP collector endpoint. With http/protobuf, a base URL: spans are sent to /v1/traces under it |
OTEL_EXPORTER_OTLP_TIMEOUT |
10000 |
Export timeout in milliseconds. Over gRPC it also bounds connecting (TLS handshake included), so an attempt that connects first can take up to twice this, and on Linux it sets when a stalled connection is closed (Span export errors in the log) |
OTEL_EXPORTER_OTLP_HEADERS |
(unset) | Authentication headers: key=value,key2=value2 |
OTEL_SERVICE_NAME |
oxphp |
Service name in exported spans |
OTEL_SERVICE_VERSION |
(unset) | Service version attribute |
OTEL_RESOURCE_ATTRIBUTES |
(unset) | Additional resource attributes: env=prod,region=us-east-1 |
OTEL_TRACES_SAMPLER |
parentbased_traceidratio |
Sampling strategy: always_on, always_off, traceidratio, parentbased_always_on, parentbased_always_off, parentbased_traceidratio |
OTEL_TRACES_SAMPLER_ARG |
1.0 |
Sampling ratio (0.0 to 1.0) for ratio-based samplers |
An out-of-range or invalid OTEL_TRACES_SAMPLER_ARG is clamped to [0.0, 1.0] with a warning in the log. An unknown OTEL_TRACES_SAMPLER falls back to parentbased_traceidratio, also logged.
APM
| Variable | Default | Description |
|---|---|---|
OTEL_APM_ENABLED |
false |
Boolean. Enables APM: automatic instrumentation, error capture, and the PHP tracing SDK. Requires OTEL_ENABLED=true |
OTEL_APM_SLOW_QUERY_MS |
100 |
Slow query threshold in milliseconds. Database queries exceeding this get an oxphp.db.slow=true span attribute |
OTEL_APM_DB_CAPTURE_PARAMS_ENABLED |
false |
Boolean. Records bind parameters in the db.params span attribute; leave it off in production if parameters may contain sensitive data |
OTEL_APM_STACKTRACE_MAX_BYTES |
8192 |
Maximum size in bytes of the exception.stacktrace attribute, truncated from the tail with a …(truncated) marker. 0 disables truncation |
OTEL_APM_MESSAGE_MAX_BYTES |
4096 |
Maximum size in bytes of the exception.message attribute (the default is New Relic's per-attribute value limit), truncated from the tail with a …(truncated) marker. 0 disables truncation |
With APM enabled, OxPHP hooks 34 internal PHP functions (PDO, mysqli, cURL, Redis, Memcached, file I/O) to create child spans. The oxphp_apm_*() functions are registered either way; with APM off, the span functions are no-ops returning sentinel values. oxphp_apm_trace() still runs its callback and returns its value, so turning APM off never changes what your application computes.
Async workers
| Variable | Default | Description |
|---|---|---|
ASYNC_WORKERS |
0 (disabled) |
Dedicated async worker threads. With 0, oxphp_async() and the other async functions exist but throw OxPHP\Async\AsyncException on call |
ASYNC_QUEUE_CAPACITY |
ASYNC_WORKERS × 64 |
Maximum pending tasks in the async queue. 0 = auto |
ASYNC_MAX_FIBERS |
256 |
Per-worker cap on concurrent task fibers. A dispatch past ASYNC_MAX_FIBERS × ASYNC_WORKERS tasks in flight (queued + running) is rejected at once with OxPHP\Async\AsyncException, so fan-out cannot deadlock |
The async pool runs the closures dispatched with oxphp_async(), separately from the PHP worker pool; plain request handling does not need it. A task still unawaited when its request ends is cancelled then, and so is a task dispatched by another task that ended without awaiting it, so work that has to finish must be awaited (Async Promises). A malformed value in any of these three variables (e.g. ASYNC_WORKERS=8x) is a startup error; an exactly empty value is treated as unset.
Runtime hooks
| Variable | Default | Description |
|---|---|---|
RUNTIME_HOOKS |
(off) | Lets blocking PHP builtins suspend the current fiber instead of holding the worker thread. Categories: sleep, streams, net, curl; 1, true or all enable every one, a comma-separated list only those named (e.g. RUNTIME_HOOKS=sleep,streams) |
Hooks act in worker-mode request fibers and oxphp_async() task fibers only. net needs streams listed too, and net and curl work on Linux only. A misspelled category is not an error, so check the installed set in /config (runtime_hooks). 1, true and all include every category, curl among them from 0.16.0, so a deployment that sets one of them starts suspending cURL transfers on upgrade; RUNTIME_HOOKS=sleep,streams,net keeps 0.15.0's set. What each category covers, where hooked calls do not suspend and what they cost: Runtime Hooks.
Shared state
In-process concurrency primitives (OxPHP\Shared\Counter, Map, Channel, Mutex, Once, Pool, Atomic, Flag, Registry). See Shared State for the API tour.
| Variable | Default | Description |
|---|---|---|
SHARED_ENABLED |
true |
Boolean. Master switch for OxPHP\Shared\*. When off, none of its classes exist (new OxPHP\Shared\Counter() throws Error: Class "OxPHP\Shared\Counter" not found), and /__ox_shared/* and the oxphp_shared_* metrics are absent |
SHARED_MAX_ENTRIES |
100000 |
Global cap on live Shared objects (each Counter, Map, Channel, … counts as one); creating one past it throws CapacityException. Keys inside a Map do not count; bound a Map with maxEntries |
SHARED_MAX_BYTES |
1073741824 (1 GiB) |
Global cap on estimated memory across Shared objects, checked only when an object is created (CapacityException). Existing objects can keep growing, so the total can read above it |
SHARED_METRICS_ENABLED |
true |
Boolean. Toggles the oxphp_shared_* Prometheus exposition |
SHARED_INTROSPECTION_ENABLED |
true |
Boolean. Toggles the /__ox_shared/* introspection API on the internal server |
SHARED_INTROSPECTION_PREVIEW_ENABLED |
true |
Boolean. Toggles value previews in introspection responses (disable when previews could leak sensitive data) |
SHARED_CYCLE_DETECT_DEPTH |
16 |
BFS depth during cycle check. Raise for deep legitimate graphs |
SHARED_CYCLE_DETECT_EDGES |
10000 |
Edges walked during cycle check. Raise for dense legitimate graphs |
SHARED_MAX_VALUE_SIZE |
1048576 (1 MiB) |
Per-value size cap. Inserting a larger value fails fast |
SHARED_MAX_CHANNEL_BYTES |
67108864 (64 MiB) |
Per-channel total payload cap |
SHARED_LOCK_DIAGNOSTICS |
warn (strict in a debug build of the binary) |
Cross-thread deadlock detector for Shared\Mutex: off, warn (log and count cycles) or strict (also break them with DeadlockException). Lowercase only; any other value silently gives the default. See Deadlock detector |
SHARED_LOCK_POLL_INTERVAL_MS |
100 |
How often the deadlock detector scans, in milliseconds. Unused when SHARED_LOCK_DIAGNOSTICS=off |
SHARED_PREVIEW_STRING_LIMIT |
256 |
Per-string truncation in /__ox_shared/preview previews, in bytes (cut at a char boundary) |
SHARED_PREVIEW_ARRAY_LIMIT |
20 |
Entries sampled in /entry?id=… previews |
Code that must run with Shared state on or off should test class_exists('OxPHP\Shared\Counter'), not interface_exists('OxPHP\Shared\Shareable'): the extension registers that interface either way.
Profiling
Per-request profiler that writes xhprof and collapsed-stack profiles. See Profiling for output formats and viewer integration.
| Variable | Default | Description |
|---|---|---|
PROFILER_ENABLED |
false |
Boolean. Master switch. A bad value here or in PROFILER_EXCLUDE_PATHS stops the server even with the profiler off; a number in another PROFILER_* variable that does not parse silently takes its default |
PROFILER_SAMPLE_RATE |
0.0 |
Probability (0.0 to 1.0) that a request is sampled. Values outside the range are clamped |
PROFILER_EXCLUDE_PATHS |
(unset) | Comma-separated globs (PHP_DENY_PATHS syntax) kept out of PROFILER_SAMPLE_RATE sampling, e.g. /_profiler,/_profiler/**,/_wdt/**. The header trigger still profiles them |
PROFILER_AUTH_TOKEN |
(unset) | Secret the X-OxPHP-Profile header must carry, and the bearer token for the /__profiler/* routes on the internal server. Unset or empty = no token: any non-empty header value passes and the routes need no bearer. Sampling and the OxPHP\Profile\* functions never check it |
PROFILER_MAX_SPANS |
50000 |
Per-request cap on profile spans. Profiles exceeding the cap are truncated |
PROFILER_MAX_DEPTH |
0 (no cap) |
Maximum nesting depth of recorded calls, clamped to 32 (a larger value is reported at startup). Deeper calls are left out but their time is not: it reads as exclusive time of the call at the limit, and they still count against PROFILER_MAX_SPANS |
PROFILER_OUTPUT_DIR |
/tmp/oxphp-profiles |
Directory for on-disk profile files |
PROFILER_OUTPUT_FORMATS |
xhprof,collapsed |
Formats written to disk, comma-separated: xhprof, collapsed. An unknown name is skipped with a startup warning and a list with no known name writes both; an empty value turns disk output off |
PROFILER_DISK_MAX_PER_SEC |
10 |
Rate limit on profile files written to disk per second |
PROFILER_RETENTION_COUNT |
100 |
Maximum profile files kept in PROFILER_OUTPUT_DIR. Older files are pruned |
PROFILER_EXPORT_URL |
(unset) | Endpoint to POST each profile to. Disk writes continue unless PROFILER_OUTPUT_FORMATS is empty |
PROFILER_EXPORT_FORMAT |
xhprof |
Body format for PROFILER_EXPORT_URL: xhprof or collapsed, sent as is. An unknown value falls back to xhprof with a startup warning |
PROFILER_EXPORT_AUTH_TOKEN |
(unset) | Optional bearer token sent with each export request |
PROFILER_INTERNAL,PROFILER_EXPORT_XHGUI,PROFILER_EXPORT_BUGGREGATOR,PROFILER_EXPORT_APP_NAMEandPROFILER_EXPORT_TAGSare gone and ignored if still set.PROFILER_EXPORT_URLreceives the bodyPROFILER_EXPORT_FORMATnames with no envelope, so pushing to xhgui (/run/import) or Buggregator (/api/profiler/store) needs an adapter in front that wraps it.speedscopeandpprofare no longer formats, andPROFILER_OUTPUT_FORMATSdefaults toxhprof,collapsed.- An
OXPROFcookie or a__oxprofquery parameter no longer starts a profile. Send theX-OxPHP-Profileheader, or callOxPHP\Profile\start()from the script.
See Profiling.
Example configurations
Development
LISTEN_ADDR=127.0.0.1:8080
DOCUMENT_ROOT=./public
LOG_LEVEL=debug
ACCESS_LOG=all
PHP_WORKERS=1
INTERNAL_ADDR=127.0.0.1:9090Production (Framework)
LISTEN_ADDR=0.0.0.0:80
DOCUMENT_ROOT=/var/www/html/public
ENTRY_FILE=index.php
PHP_WORKERS=8
QUEUE_CAPACITY=1024
LOG_LEVEL=warn
ACCESS_LOG=error
MAX_CONNECTIONS=10000
INTERNAL_ADDR=127.0.0.1:9090
RATE_LIMIT=100
RATE_WINDOW_SECONDS=60
TRUSTED_PROXIES=private
HEADER_TIMEOUT_SECONDS=5
DRAIN_TIMEOUT_SECONDS=25
COMPRESSION_BROTLI_LEVEL=5
COMPRESSION_ZSTD_LEVEL=6
COMPRESSION_GZIP_LEVEL=6
STATIC_MAX_AGE=30dProduction (Worker Mode)
LISTEN_ADDR=0.0.0.0:80
DOCUMENT_ROOT=/var/www/html/public
WORKER_MODE_ENABLED=true
ENTRY_FILE=../worker.php
PHP_WORKERS=8
WORKER_MAX_MEMORY_MIB=128
QUEUE_CAPACITY=1024
LOG_LEVEL=warn
ACCESS_LOG=error
INTERNAL_ADDR=127.0.0.1:9090TLS
LISTEN_ADDR=0.0.0.0:443
TLS_CERT=/etc/ssl/oxphp/cert.pem
TLS_KEY=/etc/ssl/oxphp/key.pem
DOCUMENT_ROOT=/var/www/html/public
ENTRY_FILE=index.phpInspecting active configuration
When the internal server is running, query the /config endpoint to see the resolved configuration:
curl -s http://localhost:9090/config | jq .{
"access_log": "all",
"async_in_flight_cap": 0,
"async_max_fibers": 256,
"async_queue_capacity": 0,
"async_workers": 0,
"brotli_level": 5,
"deny_file": {"loaded": false},
"document_root": "/var/www/html/public",
"drain_timeout_seconds": 25,
"entry_file": "/var/www/html/public/index.php",
"entry_only": false,
"executor_type": "sapi",
"gzip_level": 6,
"header_timeout_seconds": 5,
"listen_addr": "0.0.0.0:443",
"log_level": "warn",
"max_connections": 10000,
"max_query_body": 524288,
"php_workers": "8",
"plugins": {
"apm": {
"db_capture_params": false,
"enabled": true,
"hooks_registered": 34,
"slow_query_ms": 100
},
"otel": {
"enabled": true,
"protocol": "grpc",
"service_name": "oxphp"
}
},
"queue_capacity": 1024,
"queue_max_waiting": 1024,
"queue_max_waiting_bytes": 67108864,
"queue_wait_timeout_ms": 1000,
"rate_limit": 100,
"rate_window_seconds": 60,
"response_buffer_bytes": 1048576,
"response_spool_max_bytes": 1073741824,
"runtime_hooks": [],
"static_max_age": 2592000,
"static_revalidate": false,
"superglobals_enabled": true,
"tls_enabled": true,
"tls_min_version": "1.2",
"tokio_workers": 4,
"trace_context": true,
"trusted_proxies": false,
"worker_max_memory_mib": 0,
"worker_mode_enabled": false,
"zstd_level": 6
}/config leaves out the TLS certificate and key paths (tls_enabled says whether TLS is on), internal_addr and error_pages_dir. Deployment topology and filesystem paths help an attacker and are not needed by metrics scrapers.
Prompts for your agent
These prompts assume an agent with the OxPHP documentation MCP server connected. The agent reads the pages it needs itself.
Tune OxPHP for my project. Read the `operations/configuration` and `operations/sizing-workers` pages through the OxPHP documentation MCP server.
Look at what this repository runs (the framework, the worker count it can afford, the request shapes it serves) and give me a production environment block with a reason for every value you pick.Review my OxPHP configuration. Read the `operations/configuration` page through the OxPHP documentation MCP server.
Compare the environment variables this repository sets against the defaults, and tell me which of my overrides are doing nothing, which are risky, and which defaults I should have overridden and did not.See also
- Routing: routing modes and
ENTRY_FILEbehavior - Sizing PHP Workers: the pool, the queue and the waiting set against each other and against
MAX_CONNECTIONS - Diagnosing Overload: the queue, admission and wait-budget metrics, and what the server logs while it sheds requests
- Runtime Hooks: the
RUNTIME_HOOKScategories and where hooked calls do not suspend - Health Checks: internal server endpoints
- Metrics: Prometheus-compatible metrics reference
- Graceful Shutdown: how
DRAIN_TIMEOUT_SECONDSaffects shutdown - Command-Line Interface: validating a configuration with
oxphp config --check - TLS: TLS setup and certificate requirements
- Rate Limiting: per-IP rate limiting details
- Worker Mode: persistent PHP worker architecture
- Compression: codec selection and per-coding levels
- Static Files: caching and file serving
- Distributed Tracing & APM: OTel export, auto-instrumentation, and PHP tracing SDK