Skip to content / Aller au contenu
php127.hazyhaar.fr
Theme / Thème

Installing php127

php127 is a single binary. This article describes the build and execution modes used by the team, without assuming that readers have the code or binary. The quoted commands document internal operations, not a procedure to run. The historical description applies as of 2026-11-21, revision 11f6d94; it comes mainly from cmd/php127/options.go, which defines the options, cmd/php127/main.go, cmd/php127/ini_options.go and sapi/fpm/config.go.

Building the binary

php127 was a Go module requiring Go 1.27. The team built the binary without linking C libraries:

CGO_ENABLED=0 go build -o php127 ./cmd/php127

The resulting binary called no C library. Extensions were linked into the binary; the team checked its version and modules with the following commands:

./php127 -v
./php127 -m

The first command printed PHP 8.3.6 (cli) (php127 Go 1.27): php127 identified itself as PHP 8.3.6, the reference version. The second listed loaded modules, in the format of php -m. This list told the team which extensions were present.

The command line

The options followed those of PHP. The team ran a file by passing it as an argument or with -f, and a snippet of code with -r:

./php127 script.php arg1 arg2
./php127 -r 'echo PHP_VERSION, "\n";'
./php127 -l script.php

The -l option checks the syntax without running anything. A directive is set with -d key=value, which can be repeated, and a configuration file is named with -c.

One point differs from PHP and is worth knowing before any deployment: php127 does not look for a php.ini by default. The file is only read if -c names it (cmd/php127/ini_options.go); if -c points to a directory, php127 reads php.ini inside it, and a path that does not exist is ignored without a message. The options -n, -q, -F, -O, --force-stderr, --nodaemonize and --allow-to-run-as-root are accepted so that existing scripts keep working, but they have no effect.

The built-in HTTP server

As with php -S, the team could serve a directory over HTTP:

./php127 -S 127.0.0.1:8080 -t /srv/site

Without -t, the document root was the current directory. The code thus defined a built-in HTTP mode distinct from FastCGI; this description is not a load measurement.

FastCGI and FPM-style configuration

For FastCGI mode, the team used -b, or loaded a configuration in the PHP-FPM format with -y (or --fpm-config):

./php127 -b 127.0.0.1:PORT
./php127 -y /etc/php127/pool.conf
./php127 -t -y /etc/php127/pool.conf

The third line tests the file without starting the service; an invalid file makes the program exit with code 78. The modes exclude each other: -S cannot be combined with -b or -y, and -r cannot be combined with any server mode.

The pool file understands the directives listen, listen.allowed_clients, pm, pm.max_children, pm.max_requests, request_terminate_timeout, pm.status_path, ping.path and clear_env, as well as the env[…], php_value[…] and php_admin_value[…] families. One difference matters for security: user, group, chroot and security.limit_extensions are accepted without error, but without effect (sapi/fpm/config.go). php127 therefore does not switch users and does not confine itself; it is up to the service manager to start it under the right account.

Behind nginx

The site that publishes this blog follows this layout: nginx accepts connections, terminates TLS, serves static files itself and hands PHP scripts to php127 through fastcgi_pass to a local address. Each application, the shop and the blog, has its own php127 process, its own system user and its own systemd unit, hardened with NoNewPrivileges, ProtectSystem=strict, ProtectHome, PrivateTmp and PrivateDevices. The MariaDB database listens on no network port; both applications reach it through the Unix socket.

On the nginx side, php127 reads the script path from the FastCGI parameter SCRIPT_FILENAME (sapi/fpm/env.go); the rest comes down to the fastcgi_pass address:

location ~ \.php$ {
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_pass 127.0.0.1:PORT;
}

Only nginx is described here, because it is the front end of this site. Another front end that speaks FastCGI should be configured the same way, but we have not measured it.

Blocking outbound traffic

At reference revision 5b31e86, PHP127_BLOCK_EXTERNAL=1 makes cURL refuse addresses outside the loopback (cmd/php127/services.go, extxmlcurl/curl.go). This check covers neither sockets nor the MySQL driver. The WordPress bench uses it alongside WordPress's own HTTP restrictions; it is not a process-wide firewall.

What installation does not do

Installation creates neither a database nor an account: WordPress and PrestaShop are then installed as usual, with their own setup wizards. Nor does it set open_basedir for you; the article on security explains what this directive covers in php127. Finally, remember that php127 has no PostgreSQL driver: an application that depends on it will not work.

Lire en français