Docs cipi.yml Web panel API MCP Guides Compare GitHub Telegram channel
  1. Home
  2. Guides
  3. Laravel Octane with FrankenPHP on your own server
Laravel

Laravel Octane with FrankenPHP on your own server

Serve Laravel from memory with Octane and FrankenPHP, side by side with PHP-FPM apps, with pinned builds, safe upgrades and zero-downtime reloads.

By Updated 3 min read

Laravel Octane boots your app once and keeps it in memory, so each request skips the framework bootstrap. With FrankenPHP as the server, a typical app answers several times faster on the same hardware. Cipi runs it natively, without containers, next to your PHP-FPM apps.

Laravel Octane
$ cipi app create shop --octane
$ cipi app convert legacy --to=octane
$ cipi frankenphp upgrade --all

Key ideas, in plain words#

TermMeaning
PHP-FPMThe classic way: PHP boots Laravel for every request
OctaneBoots Laravel once and keeps it in memory; requests reuse it
FrankenPHPA modern PHP server (one binary with PHP inside) that Octane runs on
Octane workerOne long-lived process handling requests in turn
State leakData from one request still in memory during the next: the main thing to avoid
Step 1 of 2PHP-FPM

Classic PHP: for every request, Laravel boots (config, providers, routes), handles the request, then everything is thrown away.

Before you start#

  • A Laravel app on Cipi (first deploy) with a test suite.
  • About 150 MB of free RAM per Octane worker you plan to run.

1. Prepare the project#

bash
composer require laravel/octane
php artisan octane:install --server=frankenphp

Commit both changes. Octane apps keep state between requests: avoid storing per-request data in static properties or singletons. The Octane docs list the patterns to watch.

2. Create the app as Octane, or convert one#

bash
sudo cipi app create --user=shop --domain=shop.example.com \
    --repository=git@github.com:acme/shop.git --octane
sudo cipi deploy shop

An existing app moves over (and back) in one command; the certificate is kept:

bash
sudo cipi app convert shop --to=octane
sudo cipi app convert shop --to=fpm

3. What runs on the server#

Step 1 of 4Nginx

Nginx handles HTTPS and serves static files from public/ itself.

PieceSetting
NginxServes current/public directly and proxies the rest to the app's local port
ProcessSupervisor program shop-octane, next to the queue workers
.envOCTANE_SERVER=frankenphp, OCTANE_HTTPS=true
DeploysThe pinned binary is linked into the new release, then Octane reloads

4. Tune the workers#

bash
sudo cipi app limits shop --octane-workers=4

Start with one worker per CPU core and watch memory with sudo cipi status. Long jobs belong on queues or Horizon, WebSockets on Reverb.

5. Keep FrankenPHP patched, safely#

bash
sudo cipi frankenphp              # each app's build and PHP, patched or not
sudo cipi frankenphp upgrade shop  # newest build on the same PHP minor
GuardEffect
Upgrades stay on the app's PHP minorNo surprise PHP jump
Octane must answer after an upgradeOtherwise the previous build comes back
Nightly patches via cipi autoupdateSecurity fixes without manual work

To move to a new PHP minor: sudo cipi app edit shop --php=8.6, then sudo cipi frankenphp upgrade shop.

In cipi.yml#

The runtime is chosen at creation or with convert; worker counts can live in the repository:

yaml
app:
  limits: { octane_workers: 4 }

Avoid state leaks#

RiskySafer
static $cache = [] in a serviceLaravel's cache, or reset it per request
Injecting Request into a singleton's constructorResolve the request inside the method
Singletons holding the logged-in userBind as scoped() instead of singleton()
Growing arrays in long-lived objectsOctane recycles each worker after 500 requests by default, which limits the damage, not the cause

Troubleshooting#

ProblemFix
502 Bad GatewayOctane isn't running: sudo cipi worker list shop, then sudo cipi app logs shop --type=worker
One user sees another's dataA state leak: see the table above
.env change ignoredcipi app artisan shop config:cache, then cipi worker restart shop
Memory climbs until restartA leak in a long-lived object: find it (static arrays, listeners added per request); lower the worker count meanwhile
cipi php upgrade lists the appIts FrankenPHP build is behind: sudo cipi frankenphp upgrade shop
Uploads larger than a few MB failRaise client_max_body_size and upload_max_filesize with cipi ini

Questions

Do I need Docker for FrankenPHP?

No. Cipi runs the FrankenPHP binary natively under Supervisor, behind Nginx, like any other process.

Can Octane and PHP-FPM apps share a server?

Yes. Each app picks its runtime; you can convert one back and forth with cipi app convert.

Will a deploy change my PHP version?

No. Each Octane app is pinned to a FrankenPHP build. PHP changes only when you run cipi frankenphp upgrade or switch the app's PHP version.

Is Octane always faster?

For most apps, yes: requests skip the framework boot. Apps dominated by slow database queries or external APIs gain less; fix those first.

What breaks under Octane?

Code that keeps per-request data in static properties, singletons resolved once with the request inside, or global state. Test with php artisan octane:start --watch locally.

How much memory does it use?

Each Octane worker keeps the app in memory, often 60–150 MB. Workers × memory must fit alongside your database and queues.

How do I reload Octane after changing .env?

Rebuild the config cache and restart: cipi app artisan shop config:cache, then cipi worker restart shop. A deploy does both.

Try it on your own server

Free and open source. One command on a fresh Ubuntu 24.04 or 26.04 VPS.

wget -O - https://cipi.sh/setup.sh | bash
Read the quickstart