Blueprints · Laravel & PHP
Production
30 min · FrankenPHP / Octane
Laravel Octane with FrankenPHP
Runs Octane under systemd with a 500-request worker recycle, proxies it through Nginx, and turns on OPcache JIT for the CLI that serves Octane.
Live config
Baked-in protections
- Octane listens on 127.0.0.1 only
- Workers recycle after 500 requests
- The service user is not root
- OPcache is enabled with a small JIT buffer
Step 1 · ini
systemd unit
/etc/systemd/system/octane.service
Install FrankenPHP on the host first. This unit only supervises the Octane process.
[Unit] Description=Laravel Octane After=network.target [Service] User=deploy Group=deploy WorkingDirectory=/var/www/app/current ExecStart=/usr/bin/php artisan octane:start --server=frankenphp --host=127.0.0.1 --port=8000 --max-requests=500 Restart=always RestartSec=3 NoNewPrivileges=true PrivateTmp=true [Install] WantedBy=multi-user.target
Step 2 · nginx
Nginx upstream and OPcache
/etc/nginx/sites-available/app.example.com.conf
JIT buffer is 64M. Raise it only after you have free RAM.
server {
listen 80;
server_name app.example.com;
server_tokens off;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
Step 3 · bash
Enable Octane
/root/portgate-blueprints/octane-enable.sh
Writes the OPcache file and reloads PHP-FPM only if that service exists. Octane itself is PHP CLI.
#!/bin/sh set -eu cat > /etc/php/8.4/mods-available/portgate-opcache.ini <<'EOF' opcache.enable=1 opcache.enable_cli=1 opcache.jit=tracing opcache.jit_buffer_size=64M EOF systemctl daemon-reload systemctl enable octane.service systemctl restart octane.service || echo "Octane did not start. Install FrankenPHP and the app first." ln -sfn "/etc/nginx/sites-available/app.example.com.conf" /etc/nginx/sites-enabled/app.example.com.conf nginx -t systemctl reload nginx