# PHP versions, settings and PHP-FPM

> Run PHP 5.6 to 8.5 side by side, choose a version and php.ini values per domain, tune PHP-FPM per subscription, watch OPcache, add extensions or ionCube, and update a PHP version as one unit.

Source: https://www.berthpanel.app/library/php/ · Category: sites · Updated: 2026-10-30

Berth runs several PHP versions next to each other and lets every domain pick its own. Each subscription gets its own PHP-FPM, so one busy or broken site cannot starve the others. This article covers versions, per-domain settings, the FPM process model, OPcache, extensions and how PHP is kept up to date.

## Supported versions

PHP 5.6 up to 8.5 can be installed. Packages come from the established third-party repositories: **Sury** on Debian and Ubuntu, **Remi** on AlmaLinux and Rocky Linux.

Versions that no longer receive security fixes (such as 7.4, 8.0 and 8.1) stay available, so an old site can move to Berth first and be upgraded afterwards. The panel marks them as *outdated*, shows the date of the last security fix, and warns on the domain page and in the [site quality score](https://www.berthpanel.app/library/site-quality-scores/).

### Add or remove a version

An administrator manages versions under *System → Software*, or on the command line:

```bash
berth php version list          # installed and available versions, end of support, who uses them
berth php version add 8.4
berth php version remove 7.4    # refused while a domain, package, webmail or Adminer still uses it
```

Adding a version runs as a system job with its own live log. If someone installs a PHP version by hand outside the panel (for example `apt install php8.4-fpm`), Berth detects it and offers *Adopt PHP 8.4*. It never assigns such a version to a domain by itself.

## Choose the PHP version of a domain

On the domain page, open *Settings → PHP*, pick the version and save. An empty choice follows the package default.

```bash
berth domain php --domain example.com --version 8.3
berth domain php --domain example.com --version ""    # back to the package default
```

To move many domains at once, use *Domains → Several at once* or `berth domain bulk --action php --value 8.4 --domains …`.

## php.ini per domain

Under the same *PHP* section you set php.ini values for one website. An empty field follows the package. Typical keys:

| Setting | Example |
|---|---|
| `memory_limit` | `256M` |
| `upload_max_filesize`, `post_max_size` | `64M` |
| `max_execution_time`, `max_input_time` | `60` |
| `max_input_vars` | `3000` |
| `date.timezone` | `Europe/Amsterdam` |
| `session.gc_maxlifetime` | `1440` |
| `error_reporting` | `E_ALL & ~E_DEPRECATED` |
| `display_errors`, `log_errors`, `short_open_tag`, OPcache, `allow_url_fopen` | on or off |

A `.user.ini` in the website is honoured as well.

### Defaults and locking in the package

The package sets the defaults for every domain on it:

```bash
berth plan set --name basis --php 8.3 \
  --php-setting memory_limit=256M --php-setting upload_max_filesize=64M
berth plan set --name managed --php 8.3 --php-locked
```

With *PHP settings locked* (`--php-locked`) customers can no longer change the PHP version or php.ini of their domains; the administrator still can. For a single subscription, deviate from the package with an override:

```bash
berth subscription override --sysuser acme --php memory_limit=512M
berth subscription override --sysuser acme --set php_version=8.4
```

### Hard limits from the server policy

A hosting company may want limits that no package, override or panel action can loosen, for example a maximum `memory_limit` or an allow-list of PHP versions. Those live in the root-only server policy (`berth beleid`), described in [Web server settings](https://www.berthpanel.app/library/web-server-settings/#server-policy).

## PHP-FPM per subscription

Every subscription runs **its own PHP-FPM master per PHP version**, inside the subscription's systemd slice. Its processes run as the subscription's system user and count towards its CPU, memory and task limits. An idle pool costs very little memory. On servers with many small sites, the option *Only packages with limits* keeps the own FPM for packages that have resource limits and lets the rest share an FPM per version.

The pools are rendered and tested by the root agent itself from a typed specification, and a reload never cuts off running requests: requests in flight may finish, new ones wait briefly in the queue. See [How changes go live](https://www.berthpanel.app/library/how-changes-go-live/).

### Process model

| Model | When to use it |
|---|---|
| `ondemand` (default) | Most sites. Processes start when requests arrive and stop when idle. |
| `dynamic` | Busy sites that benefit from a few processes kept warm. |
| `static` | A fixed number of processes; for predictable, heavy load. |

The package sets the model and the maximum number of PHP processes per domain. An administrator can deviate per domain under *Speed → PHP processes*:

```bash
berth plan set --name basis --fpm-pm ondemand --fpm-max-children 5
berth domain fpm --domain example.com --pm dynamic --max-children 12
berth domain fpm --domain example.com --reset
```

The same section shows how many processes are busy, the peak since the last start, memory use and slow requests, with advice when the pool was full. A slow request log is kept per domain; open it from the section or with `berth domain logs --domain example.com --kind php_slow`.

## OPcache dashboard

*Admin → PHP* shows, per PHP version, the occupancy of every pool (full pools, slow requests) and the OPcache state: memory used, cached files, interned strings, hit rate, with advice when the cache is too small. OPcache memory, the number of files, interned strings and JIT are configurable per version:

```bash
berth php status
berth php opcache --version 8.3 --memory 256 --files 20000 --jit --jit-buffer 64
```

Because OPcache is shared by the sites on one PHP version, functions such as `opcache_reset()` and `opcache_get_status()` are not available to websites. PHP picks up new code by itself after an upload.

## Extensions and ionCube

Extra PHP extensions, such as `apcu`, are added per version under *System → Software → PHP 8.3*. Only extensions from Berth's built-in list for the operating system are offered.

```bash
berth php ext add 8.3 apcu
berth php ext remove 8.3 apcu
```

Sites encrypted with ionCube need the **ionCube Loader**. Berth downloads it only from ionCube over HTTPS, checks it against a SHA-256 you supply (or pins the hash of what ionCube delivers now), test-loads it, and enables it as the first Zend extension, followed by a config test and a PHP-FPM reload:

```bash
berth php ioncube install 8.3 --accept-license --sha256 <hash>
berth php ioncube status 8.3
```

The loader is covered by ionCube's own licence; `--accept-license` confirms you have read it. Extension and ionCube changes reload PHP-FPM, including the own FPMs of every subscription on that version.

## Hardening defaults

Every pool starts hardened. The defaults are:

- `open_basedir` limited to the subscription's home,
- `security.limit_extensions` set to `.php`,
- process functions (`exec`, `system`, `proc_open` and similar) and the OPcache control functions disabled,
- `mail()` **off** in new packages: a hacked site cannot send spam through it, and `mail()` returns `false`. Sites send mail over SMTP with a mailbox instead (WP Mail SMTP, PHPMailer),
- `expose_php` off, hardened session cookies,
- each subscription's FPM with its own `/tmp`: the webspace's `tmp/` folder, which counts towards the subscription's disk space; other processes on the server are hidden.

Two package switches relax this when a site really needs it:

| Package option | Effect |
|---|---|
| *Allow PHP mail()* (`--php-mail`) | PHP may send with `mail()`, within an hourly recipient budget per subscription |
| *PHP may start processes* (`--php-shell`) | Process functions are allowed |

Hidden files such as `.env`, `.git` and `.htaccess`, and the private folders of web shops, are never served to visitors; `.well-known` is.

## Updating PHP as one unit

The automatic security updates include PHP from Sury or Remi, within a version only patch releases. All packages of one PHP version (fpm, cli, common and the extensions) always move together: *System → Updates* shows one line per version, for example "PHP 8.3: 8.3.26 → 8.3.27, 15 packages", with **Update PHP 8.3**. The update runs with a check before and after; if the check fails, all packages go back together. The check afterwards requests every site on the updated version again: a site that worked before the update and now returns a server error makes the update count as failed. See [OS updates and maintenance](https://www.berthpanel.app/library/os-updates-and-maintenance/) and [every site is watched for server errors](https://www.berthpanel.app/library/uptime-and-status-pages/#every-site-is-watched-for-server-errors).

## Related

- [Domains and subscriptions](https://www.berthpanel.app/library/domains-and-subscriptions/)
- [Isolation](https://www.berthpanel.app/library/isolation/) for slices, quotas and outbound traffic
- [Software installer](https://www.berthpanel.app/library/software-installer/) for WordPress and other PHP applications
- [Customers and packages](https://www.berthpanel.app/library/customers-and-packages/)
