# trellis doctor: Check Your Trellis Servers for Updates

[trellis-cli v1.21.0](https://github.com/roots/trellis-cli/releases/tag/v1.21.0) adds `trellis doctor`, a command that checks whether your servers are patched and up to date, and tells you how to fix them when they aren't. [Trellis v1.34.0](https://github.com/roots/trellis/releases/tag/v1.34.0) is out too, with PHP 8.4 as the default and warnings when a server needs a reboot.

Trellis installs Nginx, PHP, and MariaDB from their own repositories, so Ubuntu's unattended-upgrades doesn't patch them, and provisioning leaves them at whatever version is already installed. After [PHP2Shell](https://roots.io/php2shell-patching-php-on-trellis-servers/), [NGINX2Root](https://roots.io/nginx2root-patching-nginx-on-trellis-servers/), and [November's PHP security release](https://roots.io/november-php-security-release-patching-php-on-trellis-servers/), checking meant SSHing into each server and reading `apt-cache policy` by hand. `trellis doctor` does that for you.

## trellis doctor

Run it from your project's `trellis` directory:

```
trellis doctor
```

With no arguments, it checks every environment except development. Here's what it looks like on a server that's fallen behind:

```
$ trellis doctor production
Local
  ✓ Trellis  v1.34.0 (latest)

production · admin@203.0.113.10
  ✓ Ubuntu               Ubuntu 24.04.3 LTS · supported until 2029-05-31
  ✗ nginx                1.31.9 → 1.31.10 available
                         apt source: http://nginx.org/packages/mainline/ubuntu noble/nginx
  ✗ php8.3-fpm           8.3.37-2 → 8.3.37-3 available
                         apt source: https://packages.sury.org/php noble/main
  ✗ mariadb-server       10.11.14 → 10.11.20 available
                         apt source: https://mirror.rackspace.com/mariadb/repo/10.11/ubuntu noble/main
  ! Reboot               Reboot required · up 177 days
                         Reboot when convenient: run `sudo reboot` on the server
  · Unattended upgrades  enabled · last ran 13 hours ago · 4 Ubuntu security updates pending for its next run

  Fix:
    Back up your databases before upgrading MariaDB
    trellis provision --tags nginx,php,mariadb --extra-vars "nginx_package_state=latest apt_package_state=latest mariadb_server_package_state=latest mariadb_client_package_state=latest" production
```

On each server, doctor compares the installed Nginx, PHP, and MariaDB packages with what their repositories offer. It also checks php.net for PHP releases, so it can tell you when a security release is out but hasn't reached your server's repository yet. Beyond the packages, it checks for a pending reboot, whether unattended-upgrades is running, how long your Ubuntu release is supported, and whether your project is on the latest Trellis.

It connects the same way `trellis provision` does. Without `--fix`, it never uses sudo or changes anything on your servers.

Doctor has no built-in list of CVEs or safe versions. Everything it knows comes from your server's apt sources, php.net, Ubuntu, and GitHub, so it doesn't go stale between trellis-cli releases.

### Fixing what it finds

When packages are outdated, doctor prints the `trellis provision` command that upgrades them. To have doctor run it for you, add `--fix`:

```
trellis doctor --fix production
```

It asks before provisioning each environment, then checks again. Upgrades stay within your configured `php_version` and `mariadb_version`, so `--fix` never moves you to a new PHP or MariaDB version.

### Running it on a schedule

With `--quiet`, doctor only prints problems and warnings, and prints nothing when everything is up to date, so it works well in cron:

```
0 7 * * 1-5 cd /path/to/site/trellis && /path/to/trellis doctor --quiet production
```

It exits with `1` when something is outdated and `2` when something couldn't be checked, such as an unreachable server. See [Keeping Trellis Servers Updated](https://roots.io/trellis/docs/server-updates/#checking-your-servers) for the details.

## Trellis v1.34.0

### PHP 8.4 by default

New projects now use PHP 8.4. Your project sets `php_version` in `group_vars/all/main.yml`, so existing servers stay on their current version until you change it:

```
php_version: "8.4"
```

The next provision installs PHP 8.4 and stops and disables the old `phpX.Y-fpm` service. If you merge Trellis updates into your project, check that file before provisioning so you don't switch by accident.

### Reboot warnings

Kernel and library updates from unattended-upgrades don't take effect until the server reboots. Provisioning and deploys now end with a warning when a server needs a reboot, listing the packages that need it and how to reboot. Trellis never reboots for you, and you can turn the check off with `--skip-tags reboot-required`.

### Also in this release

- Deploys with [WordPress runtime hardening](https://roots.io/trellis/docs/security/#wordpress-runtime-hardening) enabled now work. After upgrading, provision and then deploy.
- The fail2ban WordPress filters no longer count successful logins or Referer headers as failures, which could ban admins. Apply it with `trellis provision --tags fail2ban production`.

## Upgrading

Update trellis-cli with Homebrew:

```
brew upgrade roots/tap/trellis-cli
```

Or download a binary from the [v1.21.0 release](https://github.com/roots/trellis-cli/releases/tag/v1.21.0).

## More info

- [trellis-cli v1.21.0 release notes](https://github.com/roots/trellis-cli/releases/tag/v1.21.0)
- [Trellis v1.34.0 release notes](https://github.com/roots/trellis/releases/tag/v1.34.0)
- [Keeping Trellis Servers Updated](https://roots.io/trellis/docs/server-updates/)

Questions or problems upgrading? [Let us know!](https://discourse.roots.io/)