PHP versions
The PHP versions section of a server (/servers/:id/php) is where you install
PHP runtimes side by side, pick which version each site runs, and tune each
version’s php.ini, extensions and FPM pool. Every site gets its own isolated
PHP-FPM pool, so a legacy site can stay on 8.1 while a new one runs 8.3 on the
same box. It’s available on all plans.
Switch a site’s PHP version, step by step
Section titled “Switch a site’s PHP version, step by step”- Scroll to the Sites by PHP version panel — a full-width list of every site on the box with its current runtime.
- Find the site, hover its version, and click to open the inline version picker.
- Pick a target version. The switch is per-site and zero-downtime — the agent repoints just that site’s FPM pool and reloads, leaving every other site untouched. A spinner runs on the row until it lands.
What else you can do
Section titled “What else you can do”The top of the page is a searchable grid of version cards (one per installed runtime) with a status filter and two actions in the toolbar.
- Filter and search — segment by status (All / Active / Inactive) and search across versions, extension names, or the domains running each version.
- Install version — opens a drawer to tick which versions to add; the install streams a live progress log (apt can take a minute per version) and survives closing/reopening the drawer.
- Set as default — mark a version as the box default for new sites (a Default badge shows on the card). This does not touch running pools.
- Configure — open the per-version drawer (Settings / Extensions / FPM
tabs) to review and adjust
php.inidirectives, toggle or install extensions, and set the FPM pool baseline. There’s also a rawphp.inieditor for anything beyond the guided fields. - Restart FPM — restart a version’s shared master (
php<x.y>-fpm, or Remi’sphp<xy>-php-fpmon AlmaLinux/Rocky). The card counts the version’s dedicated masters too: an isolated site runs its ownmzfpm-<user>master, which follows the shared restart on Ubuntu/Debian; on AlmaLinux/Rocky the panel reloads each one after the shared restart. - Dedicated PHP-FPM masters — a list under the version cards with every isolated
site’s
mzfpm-<user>unit per PHP version and a Reload button (runssite.isolateon the already isolated site: a verified graceful reload; a master that does not come back puts the site on the shared master). - Uninstall — remove a version. Guarded: you can’t remove the box default, nor a version still hosting sites (move those sites first).
- Optimize — open a hardware-aware tuning plan across all versions (per-site FPM sizing from RAM + per-version OPcache + missing extensions), review the diff, and apply the levers you want.
EOL runtimes (7.4, 8.0) are still installable for legacy sites and carry an EOL / EOL soon badge so you know they’re out of security support.
Harden one site’s PHP (profiles)
Section titled “Harden one site’s PHP (profiles)”Each PHP site (WordPress, PHP, Laravel…) has a PHP hardening profile, set in the site drawer under Settings → PHP hardening (agent 0.2.159+, every plan):
| Profile | What it changes |
|---|---|
| balanced (default) | The pool every site always had: exec, shell_exec, system, passthru, proc_open, popen, curl_multi_exec, parse_ini_file, show_source and pcntl_exec disabled. Sites that never picked a profile run this, unchanged. |
| strict | balanced, plus the rest of the process family (proc_*, pcntl_*), the POSIX setters (posix_kill, posix_setuid…), dl and putenv disabled; open_basedir narrowed to the site folder, its tmp and its cache folder (where WordPress queues page-cache purges; since agent 0.2.162, re-apply strict on older sites); allow_url_include, allow_url_fopen, expose_php and display_errors off; session cookies httponly, samesite=Lax, use_strict_mode, and secure when the site has HTTPS. Upload and post size limits stay the same. |
| off | No disabled functions at all, for apps that really need to run programs. The site keeps its own user, open_basedir, its own tmp and session directory. Risk: a hacked PHP file can run any command as the site user. |
Applying a profile writes the site’s pool, runs php-fpm -t against the master that
serves it (shared or the site’s own sandboxed master) and gracefully reloads only that
master. If the test fails the old pool is put back and the job fails with
fpm_test_failed. The job output lists disabled_functions, plus
added_vs_balanced (what strict blocks on top of the default) and
allowed_vs_balanced (what off allows).
The profile is stored as PHP_PROFILE in the site registry and survives a PHP version
switch, a clone and isolating the site onto its own PHP-FPM master. If you enable HTTPS
after choosing strict, apply strict again to add the secure cookie flag.
Change php.ini for one site
Section titled “Change php.ini for one site”Each PHP site (WordPress, PHP, Laravel…) can override a set of php.ini values for itself only, in the site drawer under Settings → PHP settings (php.ini) (agent 0.2.160+, every plan). Leave a field empty to keep the server value; Reset all drops every override.
| Key | Accepted values |
|---|---|
upload_max_filesize, post_max_size | a size from 1M to 16G (256M, 1G) |
memory_limit | 32M to 16G (no -1) |
max_execution_time / max_input_time | seconds, 0–86400 (max_input_time also -1) |
max_input_vars, max_file_uploads | a number (100–1000000, 1–1000) |
display_errors, display_startup_errors, short_open_tag, opcache.validate_timestamps | On / Off |
date.timezone | an IANA zone such as Europe/Berlin, or UTC |
error_reporting | E_ALL, E_ALL & ~E_DEPRECATED & ~E_STRICT, E_ALL & ~E_NOTICE, 0 or a number |
output_buffering, session.gc_maxlifetime, default_socket_timeout, opcache.revalidate_freq | On/Off/bytes, seconds |
opcache.max_accelerated_files, opcache.interned_strings_buffer, opcache.jit_buffer_size, opcache.jit, realpath_cache_size, realpath_cache_ttl | isolated sites only (read when PHP-FPM starts) |
The values go into the site’s own PHP-FPM pool, replacing the pool’s line for the same key
(never a second copy), so they win over the server-wide php.ini. Upload size, memory and
time limits stay admin values that the app cannot raise with ini_set. A site on its own
PHP-FPM master (isolated) also gets
/etc/mz/fpm/<user>/conf.d/90-mz-site.ini, which is the only place the startup-only OPcache
and realpath cache sizes can be set; a site on the shared master answers not_isolated for
those. Every change is tested with php-fpm -t against the master that serves the site and
only that master reloads gracefully; a rejected change puts the previous files back
(fpm_test_failed). The overrides are kept in the site registry (PHP_INI) and survive a
PHP version switch, a clone and isolation. The answer warns when post_max_size is smaller
than upload_max_filesize or memory_limit is above the site’s memory cap.
Not overridable here: what the hardening profile controls (allow_url_fopen, expose_php,
session cookies, disable_functions, open_basedir), paths, and
opcache.memory_consumption (sized from the site’s resource plan).
How it works
Section titled “How it works”Actions on this page dispatch php.* jobs to the server’s agent, which runs them
natively (no shell-out to a legacy script):
| Action | Job | Agent runs |
|---|---|---|
| List versions | php.list | php list --json |
| Switch a site | php.switch | repoints one site’s FPM pool |
| Set box default | php.set-default | updates the default for new sites |
| Install / uninstall | php.install / php.uninstall | apt add/remove a runtime |
| Toggle extension | php.ext | enable/disable a loaded module |
| Install extension | php.ext-install | apt php<x.y>-<name> (or ionCube) |
Save php.ini | php.config-set / php.config-set-raw | writes managed overrides, reload-tested |
| Save FPM pool | php.fpm-set | sets the version’s pool defaults and applies them to its site pools |
| Restart pool | php.restart | reloads php<x.y>-fpm |
| Tuning plan | php.optimize / tuning.retune-all | computes/applies RAM-based sizing |
| Site hardening profile | site.php-profile | rewrites one site’s pool, php-fpm -t, reloads its master |
| Site php.ini overrides | site.php-ini | rewrites one site’s pool (+ its master’s 90-mz-site.ini when isolated), php-fpm -t, reloads its master |
Per-site isolation is the foundation. Each site runs its own PHP-FPM pool
under its own Linux user, with an open_basedir jail so it can only see its own
files. That’s what makes per-site versions (and per-site resource limits, on every plan)
possible in the first place.
Reads are cache-first. The version list comes from an agent-pushed inventory
snapshot (php), so the page loads instantly and an offline box still shows its
last-known real versions. The Configure drawer’s per-version detail (extensions +
php.ini + FPM values) is bundled into one cached php_detail snapshot, refreshed
every five minutes, on connect, and after any php.* write — so the drawer opens
instantly with a “synced X ago” indicator and a Refresh button. Writes always
run live against the online agent.
CLI & automation
Section titled “CLI & automation”Every action here maps to an mz command on the box — the same engine the
dashboard drives. SSH in and run them directly:
mz php list --json # installed versions, default, site countsmz php switch example.com 8.3 --json # move one site to a versionmz php set-default 8.3 --json # default runtime for new sitesmz php config set 8.3 memory_limit 256M --json # a php.ini directivemz php ext 8.3 imagick enable --json # toggle an extensionmz php restart 8.3 --json # reload php8.3-fpmmz site php-profile example.com --json # read the site's profilemz site php-profile example.com --set strict --json # balanced | strict | offmz site php-ini example.com --json # read the site's overridesmz site php-ini example.com --set upload_max_filesize=256M --set post_max_size=256M --jsonmz site php-ini example.com --unset memory_limit --json # or --reset for allPass a sub-action and --json for machine output. See
The mz CLI and the command catalog.
Automate it (MCP / REST)
Section titled “Automate it (MCP / REST)”MCP (mcp.mzpanel.com) and the REST API (/v1/api, same token) are on every plan.
Call jobs_schema (or GET /v1/api/job-kinds/{type}) before jobs_create /
POST /v1/servers/{id}/jobs to get each kind’s exact body, token level and scope.
| Goal | MCP tool | Job kind |
|---|---|---|
| Installed versions | php_list, servers_inventory with kind php | php.list |
| Switch one site | jobs_create | php.switch {domain, version} |
| Box default | jobs_create | php.set-default {version} |
| Install / uninstall a version | jobs_create | php.install, php.uninstall (full) |
Extensions, php.ini, FPM pool | jobs_create | php.ext, php.ext-install, php.config-set, php.config-set-raw, php.fpm-set, php.restart |
| Read or set a site’s hardening profile | jobs_create | site.php-profile {domain, profile?} (profile: balanced, strict, off; omit it to read) |
| Read or change a site’s php.ini overrides | jobs_create | site.php-ini {domain, set?: {key: value}, unset?: [key], reset?} (no change field = read; answers overrides, defaults, allowed, master_only, warnings) |
Gotchas & troubleshooting
Section titled “Gotchas & troubleshooting”- FPM tab = per-version defaults for the per-site pools. MZPanel runs a
dedicated pool per site, sized from RAM. Editing the FPM tab in a version’s
Configure drawer sets that version’s pool defaults. agent 0.2.157+ copy
them into every site pool of the version (and every new one), test the config
with
php-fpm -tand reload gracefully; a rejected value changes nothing (fpm_test_failed). A site with a concurrency cap keeps its ownpm.max_children. Older agents only record the values. To re-size the pools from RAM instead, use Optimize (the same sizing site-create uses). - A plugin broke after switching to strict. Read the job output’s
added_vs_balancedand the site’s~/logs/php-error.log(Call to undefined functionor “has been disabled for security reasons”), then go back to balanced.fpm_test_failedmeans php-fpm rejected the pool; nothing changed. Agents older than 0.2.159 answersite.php-profilewith exit 127 (update the agent). - A php.ini override was refused.
bad_key= not on the allowlist above;bad_value= outside the accepted range (the message gives it);not_isolated= a startup-only key on a site that shares the PHP-FPM master (isolate the site first);profile_conflict=display_errors=Onwhile the strict hardening profile forces it off. Agents older than 0.2.160 answersite.php-iniwith exit 127. - Uninstall is guarded. You can’t remove the box default or a version that still hosts sites — move those sites to another version first, or set a different default. The card’s Uninstall action is disabled with the reason on hover.
- Set default doesn’t move existing sites. It only changes which runtime new sites get. Existing sites keep their version until you switch them explicitly.
- Installing a version can take a minute. It’s an apt install; the progress log streams live — leave it running even if you close the drawer.
- Offline servers are read-only. With the agent offline the page shows the last-known versions from cache behind an agent-offline banner; installing, switching, restarting and saving all need the agent online.
Related
Section titled “Related”- Server overview — the server’s status and sections.
- Cron jobs — scheduled tasks on the same box.
- Site overview — where a single site’s PHP version shows.
- The mz CLI — driving the box from the command line.