PHP-FPM autostart: firewall and verification after reboot

Connect the complete original history to one-time PHP-FPM startup. After a separate reboot, verify the persistent firewall, automatic service activation, Unix sockets and FastCGI from both pools.

A firewall before two PHP pools, an enabled switch and a reboot ring.

PHP-FPM must start automatically after a reboot, wait for the firewall and answer through the intended Unix sockets. We test this on an isolated local Debian VM with PHP 8.5.12. We first start the service through its separate CLI operation, then reboot the VM and observe the new state.

The starting point

The VM has completed kernel preparation, its first reboot, administrator access, utilities, Nginx and PHP-FPM configuration for two separate applications. Its package history contains seven records and two boundaries: the first reboot and PHP repository setup. After another controlled reboot, PHP-FPM is inactive with automatic startup disabled. The persistent firewall is already active.

For this local run, 24 kernel, utility and Nginx archives were preloaded into the standard APT cache with version, size and SHA-256 checks. The original CLI acquired PHP archives. The fixture network adapter relays end-to-end HTTPS through a restricted local CONNECT proxy and uses DNS-over-HTTPS for public repository addresses. Normal TLS certificate and APT signature checks remain enabled.

A separate startup plan

We use the local development version of the CLI. A Bash array holds the shared arguments; variables name private approval, configuration and access paths. Passwords and key contents stay out of the command line. STARTUP_BOOT_REQUEST proves the specific boot in which we start the service.

STARTUP_INPUTS=(
  --root-env-file "$ORIGINAL_ROOT_ENV"
  --env-file "$ADMIN_ENV"
  --request-file "$FIRST_POSTBOOT_REQUEST"
  --current-request-file "$STARTUP_BOOT_REQUEST"
  --references-file "$RUNTIME_REFERENCES"
  --fpm-file "$FPM_PROFILE"
  --key-file "$PUBLIC_REPOSITORY_KEY"
  --key-sha256 "$PUBLIC_REPOSITORY_KEY_SHA256"
  --activation-file "$PHP_ACTIVATION_REFERENCE"
  --firewall-pin-file "$FIREWALL_REFERENCE"
)

deploy-cli host runtime-startup fpm prepared-plan \
  "${STARTUP_INPUTS[@]}" --plan-file "$STARTUP_PLAN"

Planning reads the complete history and verifies original initialization. The original root profile is admitted locally; remote commands use the administrator and sudo. Startup requires the original PHP activation approval and the exact installed firewall reference.

The firewall dependency

Startup creates the separate /etc/systemd/system/deploy-cli-php85.service.d/80-deploy-cli-startup.conf drop-in. This is its configuration from the actual run.

[Unit]
Requires=deploy-cli-firewall-boot.service
After=deploy-cli-firewall-boot.service

[Service]
Type=notify
NotifyAccess=main

Requires pulls in the dependency and After defines startup order. Together they delay PHP-FPM until firewall service activation finishes and prevent startup if activation of that dependency fails. The CLI also independently observes actual firewall state.

systemd.unit(5)

Type=notify waits for a service readiness notification; NotifyAccess=main admits notifications from the main process. The CLI additionally checks processes, Unix sockets and FastCGI responses from both pools.

systemd.service(5)

One startup and fresh verification

STARTUP_PLAN_SHA256 holds the plan_sha256 field from the planning response. We apply that exact plan once. A separate command then verifies the result. We do not repeat the original PHP activation.

deploy-cli host runtime-startup fpm prepared-apply \
  "${STARTUP_INPUTS[@]}" --plan-file "$STARTUP_PLAN" \
  --plan-sha256 "$STARTUP_PLAN_SHA256" --approve-privileges

deploy-cli host runtime-startup fpm prepared-verify \
  "${STARTUP_INPUTS[@]}" --plan-file "$STARTUP_PLAN" \
  --plan-sha256 "$STARTUP_PLAN_SHA256"

These selected fields come from the actual apply response. The service is running, readiness is verified and automatic startup is enabled. We retain checks.manifest_sha256 from the complete response as STARTUP_MANIFEST_SHA256.

{
  "status": "passed",
  "action": "fpm-startup-apply",
  "write_performed": true,
  "access_verified": true
}

What happened after reboot

We reboot only the VM as a separate fixture operation. A new serial-console observation proves the same machine and a different boot. We then run verification only: NEW_BOOT_REQUEST contains fresh console evidence and STARTUP_MANIFEST_SHA256 pins the completed startup.

The interactive form of the controlled reboot, only on the test VM:

sudo -k -- /usr/bin/systemctl reboot
deploy-cli host runtime-startup fpm prepared-boot-verify \
  "${STARTUP_INPUTS[@]}" --plan-file "$STARTUP_PLAN" \
  --plan-sha256 "$STARTUP_PLAN_SHA256" \
  --new-boot-request-file "$NEW_BOOT_REQUEST" \
  --manifest-sha256 "$STARTUP_MANIFEST_SHA256" \
  --output-file "$BOOT_PROOF"
{
  "status": "passed",
  "action": "verified-after-reboot",
  "write_performed": false,
  "access_verified": true
}

PHP-FPM started automatically. These selected systemd properties come from the new boot. The firewall is active and PHP-FPM is running and remains enabled. Verification also observes fresh process identity, sockets and FastCGI; old runtime values are not projected onto the new boot.

systemctl show deploy-cli-php85.service deploy-cli-firewall-boot.service \
  --property=UnitFileState,ActiveState,SubState,Result

These selected systemctl show values are grouped by unit name as JSON. This is a shortened representation of the actual result.

{
  "deploy-cli-php85.service": {
    "Result": "success",
    "ActiveState": "active",
    "SubState": "running",
    "UnitFileState": "enabled"
  },
  "deploy-cli-firewall-boot.service": {
    "Result": "success",
    "ActiveState": "active",
    "SubState": "exited",
    "UnitFileState": "enabled"
  }
}

An incorrect completion fingerprint and stale console evidence were refused. The reads preserved all seven package records and both boundaries. PHP-FPM is a completed individual step; Nginx, data-service startup and the complete wizard have their own sequence.

The frame shows a genuine VTE terminal summarizing saved results from the local run. Capturing it repeats neither startup nor reboot.

PHP-FPM autostart after reboot with a ready firewall
  1. Operations & Security A new server boot: separate firewall acceptance through CLI
  2. Platform Engineering Original server preparation in Nginx and PHP history
  3. Platform Engineering Verify PHP-FPM before handing over to Nginx
  4. Platform Engineering Nginx autostart: the PHP-FPM dependency and verification after reboot