Deploying Laravel
A production Laravel deployment on PAM has the same moving parts on every platform:
- Build an immutable release: dependencies, framework caches, migrations.
- Run the HTTP cluster (
pam start pam.php) and, separately, queue workers and the scheduler. - Gate traffic on the admin
/readyendpoint. - Reload with
SIGHUPto switch to new code with zero downtime.
Building a Release
Section titled “Building a Release”pam composer install --no-dev --classmap-authoritative --no-interactionpam artisan optimizepam artisan migrate --forceThen check the result:
pam artisan pam:check-productionStarting the Cluster
Section titled “Starting the Cluster”APP_ENV=production \PAM_HOST=127.0.0.1 \PAM_PORT=3000 \pam start pam.php \ --workers 8 \ --max-requests 1000000 \ --admin-address 127.0.0.1:3010Pam control plane listening on http://127.0.0.1:3010● READY Pam listening on http://127.0.0.1:3000 worker=1...Pam master 989965 started 8 worker(s); send SIGHUP for zero-downtime reloadUseful flags (full list in the reference):
| Flag | Purpose |
|---|---|
--workers N |
Worker processes (one Laravel request each) |
--max-requests N |
Recycle a worker after about N requests |
--admin-address IP:PORT |
/live, /startup, /ready, /metrics |
--graceful-timeout MS |
How long draining workers may finish in-flight requests |
--startup-timeout MS |
How long a new worker may take to become ready |
Zero-Downtime Reloads
Section titled “Zero-Downtime Reloads”Send SIGHUP to the master:
kill -HUP <master-pid> # or: systemctl reload example-appPam master activated worker generation 2PAM boots a complete new generation from the current code, waits until it is
ready, then drains the old generation. The listening socket belongs to the
master, so no connection is refused. Because workers run OPcache with
validate_timestamps=0, new code is only picked up by a reload.
The typical release flow with a current symlink:
cd /srv/app/releases/20261202-1500pam composer install --no-dev --classmap-authoritative --no-interactionpam artisan optimizepam artisan migrate --forceln -sfn /srv/app/releases/20261202-1500 /srv/app/current.nextmv -T /srv/app/current.next /srv/app/currentsystemctl reload example-apppam artisan queue:restartRoll back by pointing current at the previous release and reloading again.
systemd
Section titled “systemd”Run each role as its own unit.
[Unit]Description=Example app (PAM HTTP)After=network-online.targetWants=network-online.target
[Service]Type=simpleUser=www-dataWorkingDirectory=/srv/app/currentEnvironment=APP_ENV=productionEnvironment=PAM_HOST=127.0.0.1Environment=PAM_PORT=3000Environment=PAM_LARAVEL_STORAGE_PATH=/var/lib/example-appEnvironmentFile=-/etc/example-app/pam.envExecStart=/usr/local/bin/pam start pam.php --workers 8 --max-requests 1000000 --admin-address 127.0.0.1:3010ExecReload=/bin/kill -HUP $MAINPIDKillSignal=SIGTERMKillMode=mixedTimeoutStopSec=45sRestart=alwaysRestartSec=2sLimitNOFILE=1048576StateDirectory=example-appNoNewPrivileges=yesPrivateTmp=yesProtectSystem=strict
[Install]WantedBy=multi-user.target[Unit]Description=Example app (queue worker)After=network-online.target
[Service]User=www-dataWorkingDirectory=/srv/app/currentEnvironment=APP_ENV=productionExecStart=/usr/local/bin/pam artisan queue:work --sleep=1 --tries=3 --max-time=3600Restart=alwaysRestartSec=2s
[Install]WantedBy=multi-user.target[Unit]Description=Example app (scheduler)After=network-online.target
[Service]User=www-dataWorkingDirectory=/srv/app/currentEnvironment=APP_ENV=productionExecStart=/usr/local/bin/pam artisan schedule:workRestart=always
[Install]WantedBy=multi-user.targetsystemctl daemon-reloadsystemctl enable --now example-app example-app-queue example-app-schedulersystemctl reload example-app # zero-downtime deployProtectSystem=strict makes the release read-only; StateDirectory= creates
/var/lib/example-app, which PAM_LARAVEL_STORAGE_PATH points Laravel’s
storage at. Build bootstrap/cache during the release; add ReadWritePaths= for any other directory the app writes to.
Docker
Section titled “Docker”FROM debian:bookworm-slim
RUN apt-get update \ && apt-get install -y --no-install-recommends ca-certificates curl \ && rm -rf /var/lib/apt/lists/*
ENV PAM_INSTALL_DIR=/opt/pam PAM_BIN_DIR=/usr/local/binRUN curl -fsSL https://pamphp.com/install | sh \ && pam --version
WORKDIR /appCOPY . .RUN pam composer install --no-dev --classmap-authoritative --no-interaction \ && chown -R www-data:www-data storage bootstrap/cache
USER www-dataENV APP_ENV=production APP_DEBUG=false PAM_HOST=0.0.0.0 PAM_PORT=8000EXPOSE 8000HEALTHCHECK --interval=10s --timeout=3s CMD curl -fsS http://127.0.0.1:3010/ready || exit 1CMD ["sh", "-c", "pam artisan optimize && exec pam start pam.php --workers ${PAM_WORKERS:-4} --admin-address 127.0.0.1:3010"]vendornode_modules.envstorage/logs/*.gitdocker build -t example-app .docker run --rm -p 8000:8000 --env-file .env.production example-apppam artisan optimize runs at container start so the configuration cache sees
the runtime environment. PAM_HOST=0.0.0.0 is required inside a container;
the admin listener stays on the container’s loopback for the health check.
Run queue workers and the scheduler from the same image with a different command:
services: app: build: . env_file: .env.production ports: ["8000:8000"] queue: build: . env_file: .env.production command: ["pam", "artisan", "queue:work", "--sleep=1", "--tries=3", "--max-time=3600"] scheduler: build: . env_file: .env.production command: ["pam", "artisan", "schedule:work"]Kubernetes
Section titled “Kubernetes”apiVersion: apps/v1kind: Deploymentmetadata: name: example-appspec: replicas: 2 selector: matchLabels: { app: example-app } template: metadata: labels: { app: example-app } spec: containers: - name: app image: registry.example.com/example-app:2026.12.02 env: - { name: PAM_HOST, value: "0.0.0.0" } - { name: PAM_PORT, value: "8000" } - { name: PAM_WORKERS, value: "2" } ports: [{ containerPort: 8000 }] readinessProbe: httpGet: { path: /up, port: 8000 } livenessProbe: httpGet: { path: /up, port: 8000 } initialDelaySeconds: 10 resources: requests: { cpu: 500m, memory: 512Mi } limits: { cpu: "2", memory: 1Gi }The admin listener is on loopback, so probe Laravel’s own /up health route
(or /__pam/health with pushinbr/pam-laravel) through the application port.
Match PAM_WORKERS to the CPU limit, and run queue and scheduler Deployments
from the same image with their own command.
Laravel Forge
Section titled “Laravel Forge”Create the site as usual, then:
- Daemons. Add three daemons in the site’s directory: the HTTP cluster
(
pam start pam.php --workers 4 --admin-address 127.0.0.1:3010, withPAM_PORTset in the environment),pam artisan queue:work, andpam artisan schedule:work(or Forge’s scheduler withpam artisan schedule:run). - Nginx. Proxy the site to
127.0.0.1:$PAM_PORTas shown in Migrating From FPM. - Deploy script. Use PAM for Composer and Artisan, then reload:
$CREATE_RELEASE()
cd $FORGE_RELEASE_DIRECTORY
pam composer install --no-dev --no-interaction --prefer-dist --classmap-authoritativepam artisan optimizepam artisan migrate --force --no-interaction
$ACTIVATE_RELEASE()
$RESTART_QUEUES()Then restart the HTTP daemon from Forge (or send it SIGHUP) so the new
release is loaded. See PAM Cloud & Forge for
deployment webhooks.
PAM’s Process Manager
Section titled “PAM’s Process Manager”For a single server without systemd units, PAM can supervise the HTTP cluster
itself with a declarative pam.toml:
schema_version = 1
[applications.example-http]kind_code = 1script = "pam.php"workers = 4cwd = "."env_file = ".env"health_check_url = "http://127.0.0.1:3000/up"auto_restart = truepam config:check pam.tomlpam plan pam.tomlpam apply pam.tomlpam psThe environment file must belong to you and have mode 0600 or stricter. Kind
2 runs Laravel Octane. pam apply waits for each application to become ready,
which a queue worker never does, so supervise queue workers and the scheduler
with systemd or your platform instead.
Atomic Releases With pam:deploy
Section titled “Atomic Releases With pam:deploy”pushinbr/pam-laravel can activate a prepared release directory:
export PAM_DEPLOY_ROOT=/srv/app/releasesexport PAM_DEPLOY_CURRENT=/srv/app/currentexport PAM_DEPLOY_READINESS_URL=http://127.0.0.1:3010/ready
pam artisan pam:deploy /srv/app/releases/20261202-1500 --localpam artisan pam:deploy --local --rollbackpam:deploy checks that the release is inside PAM_DEPLOY_ROOT and contains
artisan and composer.lock, runs pam artisan optimize and (unless
PAM_DEPLOY_MIGRATE=false) pam artisan migrate --force inside it, swaps the
current symlink atomically, then polls the readiness URL for up to
PAM_DEPLOY_READINESS_TIMEOUT seconds. If readiness fails, the previous
symlink target is restored. The previous target is stored in
$PAM_DEPLOY_ROOT/.pam-previous for --rollback.
It does not signal the PAM master. Reload the cluster yourself after
activation (for example with systemctl reload example-app).