Server command-line options

Here we list command-line options, that can be passed to the compiled KPHP binary.
You pass them directly to the binary compiled with -M server mode (it's the default one).
Binaries compiled with CLI mode skip some of these options, as they are applied only to a web server.

Options and environment variables

Unlike compiler options, all server-side arguments should be passed with command-line:

./server [options]

They have no associated environment variables per each.

Most useful options (basic level)

The number of worker processes, required to be set for server (not cli) mode.
For development and testing, 1-2 workers is okay.
For production, you typically set this number a bit less than the number of CPU cores on the server.

A port for accepting HTTP connections, default empty — by default, KPHP won't listen to HTTP unless passed, so always pass this option.

A log file name, default stderr. ‘%' or ‘-%' can be used for writing different log files for each worker process. More info here.

When used once (or with value 1), prevents writing get parameters to log files.
When used twice (or with argument 2), prevents writing the whole request URI to log files.

A memory limit for the script usage, default 512M. To override, pass “{number}M” or “{number}G”.

Runs the script only once and prints the result to stdout, without starting the server.

Define a variable for ini_get() (arg format: key=value).

Define variables for ini_get() from the config file (in form key=value on each row).

A prefix for the profiler log file. When profiling is enabled, this option is mandatory.

Not so common options (intermediate level)

Show the compiled PHP code version and exit.
See the compiler option --php-code-version / KPHP_PHP_CODE_VERSION

A file name with a maximum of 40 bytes contents, it is output to stderr on every warning.
If it is numeric, it's a “version” also output to JSON error logs, default 0.
This option points to a file (not just a value), because on each redeploy/rollback it's much more handy to rewrite a file, than to update startup options.

A TCP listening backlog size, default 8192. Controls a queue size for connections waiting, described here.

A connections limit (file descriptors limit), default 65536.

An RPC port for service queries, default empty — by default, KPHP does not start listening to it.
Do not confuse it with the HTTP port! Service queries are RPC queries handled by the master process: get current statistics, get the current version, get running time, etc.

An RPC port for microservice queries, default empty — by default, KPHP does not start listening to it.
Do not confuse it with the HTTP port! Queries sent to this port are described in a TL scheme with @kphp annotation, read more about it here.

Terminates request processing after the first warning, default false.

A unique name for the KPHP server, required if several KPHP servers are launched simultaneously.

A time limit in seconds for script processing, default 30s for server mode and infinity for CLI mode. To override, pass a whole number. (You can use the s/m/h/d prefix to set the limit in seconds/minutes/hours/days)

The number of processed requests after which the script memory is remapped, default 100.

A script memory limit after which the script memory is remapped, default infinity. To override, pass “{number}M” or “{number}G”.

Uses madvise MADV_DONTNEED for freeing script memory above the limit (disables --worker-memory-to-reload option).

Locks paged memory (see mlockall MCL_CURRENT | MCL_FUTURE).

A memory limit for static buffers length (e.g. limits script output size), default 16M.

A memory limit for shared memory storage, default 256M. The maximum is “4G”.

A verbosity level for logging, default 0, in range [0,4].

A verbosity level for logging net events, default 0, in range [0,4].

A hostname for statsd service, default localhost.

A port for statsd service, default: 8125, 14880. By default, KPHP tries to connect to the 8125 port, and if fails, tries to connect to the 14880 port. To override, specify a port number (a single one).

Disables sending stats to statsd, which is enabled by default.

If launched from root, switches to this user immediately after binding the ports, default: kitten.
You can explicitly specify -u root to disable switching.

Like --user, but controls the group name, default kitten. The same: makes sense only if launched from root.

The jobs workers ratio of the overall workers number, float, from 0.0 to 1.0, default 0: no job workers are launched by default.

Rarely used options (advanced level)

Most likely, you’ll never have a need to change them.

Sets a “niceness level” for the process — nice() C++ function from unistd.h

Adjust OOM score (see /proc/[pid]/oom_score_adj).

The self hostname for the KPHP server.

Disables /etc/hosts usage in favor of system gethostbyname()

A directory with UNIX sockets.

Binds to PID the current IP address before connecting.

Forces the KPHP server to choose the interface and IP in a given subnet. Arg format: [iface:]ip[/subnet]

Forces encryption for client network activity, even on localhost and the same data-center.

A file with the AES encryption key, default /etc/engine/pass. This influences RPC encryption only. If a file is not found, a warning is output if verbosity is set, and no encryption is used. For localhost RPC queries, the encryption is also not used.

Control TCP buffers size. Arg format: number:size, default 128:1k.

A memory buffers size for udp/new tcp/binlog buffers, default 256M.

An epoll sleep time in the main cycle (between 1us and 0.5s), by default no sleep is called at all.

Forces using CRC32 instead of CRC32-C for TCP RPC protocol.

A minimum verbosity level for PHP warnings, in range of [0,3], default 0.
Controls the minimum applied value of error_reporting() PHP call.

NUMA node description for binding workers to its cpu cores / memory. {numa_node_id} is a number, and {cpus} is a comma-separated list of node numbers or node ranges.
Example: ‘0: 0-27, 55-72'.
To set up multiple NUMA nodes, use this option more than once providing different configs.

NUMA memory policy for workers. Takes effect only if --numa-node-to-bind option is used.
local — bind to a local numa node, in case out of memory take memory from the other nearest node (default);
bind — bind to the specified node, in case out of memory raise a fatal error.

Other options (VK.com proprietary)

When you run ./server --help, you'll see more options than listed above.

The rest options are related to VK.com internals and therefore are unapplicable at external configurations.