# Laravel Rust apps

> Run Laravel for Rust on your own VPS: cargo build on every deploy, blue/green releases with no downtime, migrations, a queue worker, the scheduler and rollback.

URL: https://cipi.sh/docs/laravel-rust · Last updated: 2026-12-02 · Section: Apps

A Laravel Rust app compiles to one binary that serves HTTP by itself. Cipi builds it on the server at every deploy, starts the new binary beside the old one and moves Nginx only once it answers: no downtime, and a rollback one command away.

> [!WARNING]
> Laravel for Rust is in beta, and this app type is **experimental**: commands and defaults may still change with the framework. Use it for new projects and staging before you rely on it.

A Laravel Rust app:

```console
$ sudo cipi app create --rust --user=blog --domain=blog.example.com --repository=git@github.com:acme/blog.git --engine=pgsql
✓ Build tools
→ Downloading rustup (x86_64-unknown-linux-gnu)...
→ Installing Rust (stable, minimal profile) in /opt/cipi/rust...
✓ Rust 1.99.0
→ Creating 'blog' (laravel-rust)...
✓ User   ✓ Directories   ✓ Deploy key
✓ Database blog (PostgreSQL)
✓ .env with DATABASE_URL (database-postgres)
✓ PHP-FPM 8.5 (webhook only)   ✓ Nginx → blog.example.com
✓ Blue/green slots on 127.0.0.1:3100, 3101 + queue worker — started by the first deploy
✓ Scheduler + deploy trigger   ✓ Deployer   ✓ Permissions

  Runtime:    Laravel Rust — Rust 1.99.0, blue/green on 127.0.0.1:3100, 3101
  Frontend:   npm run build  (Node 24; skipped without a package.json)
  Health:     /up     Queue: queue:work   Scheduler: schedule:run every minute
  Next: cipi deploy blog  (the first build compiles every crate: several minutes)
```

## Create one

```bash
# With a database named after the app, a queue worker and the scheduler
$ sudo cipi app create --rust --user=blog --domain=blog.example.com \
    --repository=git@github.com:you/blog.git

# On MariaDB or MySQL, no worker, no scheduler
$ sudo cipi app create --rust --user=api --domain=api.example.com \
    --repository=git@github.com:you/api.git --engine=mariadb \
    --no-queue --no-scheduler

# An API with no database of its own
$ sudo cipi app create --rust --user=edge --domain=edge.example.com \
    --repository=git@github.com:you/edge.git --no-db

# Inertia with server-side rendering
$ sudo cipi app create --rust --user=shop --domain=shop.example.com \
    --repository=git@github.com:you/shop.git --ssr
```

| Flag | Meaning | Default |
| --- | --- | --- |
| `--rust` | The app type. Also *Laravel Rust* in the wizard | |
| `--repository` | Git URL over SSH. Required | asked |
| `--db=NAME` / `--no-db` | The database made with the app, or none | a database named after the app |
| `--engine` | `mariadb` or `pgsql`: [the database](https://cipi.sh/docs/laravel-rust#database) | PostgreSQL where the server has it, otherwise the server's default |
| `--no-queue` | No queue worker | a worker runs |
| `--no-scheduler` | No scheduler | it runs every minute |
| `--ssr` | [Inertia server-side rendering](https://cipi.sh/docs/laravel-rust#ssr) | off |
| `--build` | The frontend build | `npm run build`; `npm run build:ssr` with `--ssr` |
| `--node-version` | The Node major of the frontend build: `22` or `24` | the server's default |
| `--health-path` | The route a new release must answer on | `/up` |
| `--branch`, `--env` | As for [every app](https://cipi.sh/docs/create-app#flags) | |

The first Laravel Rust app installs the toolchain: [Rust](https://cipi.sh/docs/laravel-rust#toolchain), a C compiler and the Node version of the build.

> [!NOTE]
> **Trying Laravel's own skeleton?** It has one branch, `0.x`, and builds the PostgreSQL driver only. Without `--branch` Cipi deploys the repository's [default branch](https://cipi.sh/docs/create-app#branch), and the deploy gives the build [the driver of the app's database](https://cipi.sh/docs/laravel-rust#database), PostgreSQL or not: a copy of the skeleton deploys as it is.

Until the first deploy has gone through, the domain answers `502`: nothing runs behind Nginx before a release has started.

## The database

A Laravel Rust app does not choose its database driver when it runs: the driver is **compiled into the binary**, as a Cargo feature of `laravel-rust`. The skeleton Laravel publishes enables PostgreSQL's alone. Cipi makes the binary and the app's database agree at every deploy: a driver the build lacks is **added to the build**.

| The app's database | The feature the binary needs | With Laravel's skeleton as it is |
| --- | --- | --- |
| PostgreSQL | `database-postgres` | Works: the feature is in `Cargo.toml` |
| MariaDB or MySQL | `database-mysql` | Works: the deploy adds the feature to the build |
| SQLite | `database-sqlite` | Works the same way, on an app created with `--no-db` and a `sqlite:` URL in its `.env` |

**Every deploy checks it first.** Before the frontend and before the build, Cipi asks cargo which drivers the binary will have. When the one `DATABASE_URL` asks for is among them, the build is the repository's, with nothing added. When it is not, Cipi builds with it and says so:

```text
Database driver database-mysql — added to this build by Cipi (cargo build --features laravel-rust/database-mysql)
```

That flag does what naming the feature in `Cargo.toml` does. Nothing is written to your repository, nor to its `Cargo.lock`. It adds a driver to the build, not to your code: an app that writes SQL for one engine is not made to run on another.

**In your own repository, name it anyway.** Then `cargo run`, your tests and your CI build the driver production runs on, and a committed `Cargo.lock` pins its crates:

```toml
# Cargo.toml — the skeleton's line, for a database on MariaDB or MySQL
laravel-rust = { version = "0.1", features = ["database-mysql", "redis", "sqs"] }
```

**When the deploy stops instead.** Cargo can add a feature only to a dependency of the package it builds. In a workspace without a root package, or when `laravel-rust` reaches your app through a crate of your own, the deploy stops at `rust:driver` — after a few seconds, before anything is compiled — and names the feature to add to `Cargo.toml`. Nothing changes for visitors.

**Which engine a new app gets.** PostgreSQL when the server has it, because that is the driver the skeleton names; otherwise the server's default, which is MariaDB unless you changed it. `--engine=mariadb` or `--engine=pgsql` chooses. A server gets PostgreSQL with one command, next to the engine it has:

```bash
$ sudo cipi db install pgsql
```

> [!NOTE]
> The error all this prevents reads *database connection `postgres` uses an unsupported or disabled driver*, and it comes after minutes of build. `postgres` there is the name of the framework's default connection, whatever its URL: the message means the driver of your `DATABASE_URL` is not in the binary.

### Move an app to PostgreSQL

Not something the driver asks for: this is for when you want the app on PostgreSQL. For an app that was created on MariaDB and has no data to keep:

```bash
$ sudo cipi db install pgsql                                  # once per server
$ sudo cipi db create --name=blog --engine=pgsql --app=blog   # shows the password, once
$ sudo cipi app env blog --set=DATABASE_URL=postgres://blog:PASSWORD@127.0.0.1:5432/blog
$ sudo cipi deploy blog
```

The new database is empty: nothing is copied from the old one, which stays on the server until you delete it (`sudo cipi db delete blog --engine=mariadb`).

## Before the first deploy

Three things about the repository are worth settling before the first deploy. The database driver is not one of them: [the deploy sees to it](https://cipi.sh/docs/laravel-rust#database).

| In the repository | Why |
| --- | --- |
| **`Cargo.lock`** committed | The build uses `--locked`: every deploy compiles the versions you tested. Without the file, dependencies are resolved again each time |
| **Trust the proxy** in `src/app.rs` | Nginx is in front, on the same server. Without it `request.ip()` is `127.0.0.1` and generated URLs start with `http://` |
| **The health route** | New apps answer on `/up`. If yours moved it, say where: `--health-path=/healthz` |

```rust
// src/app.rs
.with_middleware(|middleware, _| {
    middleware.trust_proxies(["127.0.0.1"]);
})
```

> [!NOTE]
> In production Laravel answers only for the host of `APP_URL` and its subdomains; another host gets `400 Bad Request`. An app with [aliases](https://cipi.sh/docs/domains) on other domains lists them with `middleware.trust_hosts([…])`.

## Where things live

```text
/home/blog/
├── current -> releases/7         # the release being served
├── releases/6/ 7/                # source, public/, resources/views, bin/app
├── shared/
│   ├── .env                      # APP_KEY, APP_URL, DATABASE_URL…
│   └── storage/                  # uploads, log files, a SQLite database
├── .cache/cipi-rust/target/      # cargo's build cache, kept between deploys
└── .cargo/                       # the crates downloaded for this app
```

The binary is copied into each release as `bin/app`, next to the folders it reads while it runs (`public/`, `resources/views/`, `storage/`). Every release has its own, so a rollback starts the binary that release was built with.

## Environment

`~/shared/.env` is linked into every release, and the binary reads it when it starts.

| Variable | Value |
| --- | --- |
| `APP_KEY` | Generated |
| `APP_ENV`, `APP_DEBUG` | `production`, `false` |
| `APP_URL` | `https://` and the app's domain. It follows `sudo cipi app edit blog --domain=…`, which also restarts the app |
| `DATABASE_URL` | `postgres://`, `mariadb://` or `mysql://` on `127.0.0.1`, for the database made with the app |
| `SESSION_DRIVER`, `CACHE_STORE`, `QUEUE_CONNECTION` | `database`. With `--no-db`: `cookie`, `memory` and `sync` |
| `LOG_CHANNEL` | `stderr`: the log of the slot. Add `,daily` for files in `storage/logs` |
| `SERVER_HOST`, `SERVER_PORT` | **Not yours**: Cipi sets them for each blue/green slot, whatever the file says |

```bash
$ sudo cipi app env blog          # edit
$ sudo cipi node restart blog     # apply: a zero-downtime restart
```

## Deploy

A Laravel Rust deploy, blue/green:

```console
$ sudo cipi deploy blog
task deploy:prepare
task rust:driver      database-postgres
task rust:assets      npm ci, npm run build
task rust:build       cargo build --release --locked
   Compiling blog v0.1.0 (/home/blog/releases/7)
    Finished `release` profile [optimized] target(s) in 48.20s
bin/app ← blog
task rust:migrate     bin/app migrate --force
task rust:switch
[cipi-node] starting release 7 on green (127.0.0.1:3101)
[cipi-node] healthy on green (HTTP 200 on /up)
[cipi-node] nginx now proxies to green
[cipi-node] stopped blue
[cipi-node] queue worker on release 7
task deploy:symlink   current → releases/7
✓ Deploy completed  (release 7, 1m52s)
```

1. **Clone** — releases/8
   The commit of the branch, with `.env` and `storage/` linked in.
2. **Check** — the database driver
   Cargo is asked which drivers the build will have. The one `DATABASE_URL` needs is [added to the build](#database) when it is missing.
3. **Frontend** — npm ci, npm run build
   When the repository has a `package.json`. An API without one skips it.
4. **Build** — cargo build --release
   At low priority, so the live release keeps its CPU. The build cache is shared between deploys: after the first one only what changed is compiled.
5. **Binary** — bin/app
   The executable of `Cargo.toml`, copied into the release.
6. **Migrate** — bin/app migrate --force
   Your migrations are compiled into the binary. They run before the switch.
7. **Switch** — blue ⇄ green
   The release starts on the idle slot. When it answers on the health route, Nginx moves to it and the old process gets time to finish its requests.
8. **Worker** — queue:work
   Restarted on the new release: a worker runs the code it was compiled with.

If the new release never answers, it is stopped and the old one keeps serving: the deploy fails with nothing published.

```bash
$ sudo cipi deploy blog
$ sudo cipi deploy blog --rollback
$ sudo cipi app deploy-config blog --no-migrate
$ sudo cipi app deploy-config blog --keep-releases=3 --build-timeout=3600
```

> [!WARNING]
> A rollback moves the code back, not the database: Laravel Rust migrations go forward only. Add columns in one release and remove them in a later one, so the previous release still runs on the new schema.

## How long a build takes

| | |
| --- | --- |
| The first deploy | Compiles every crate in release mode: several minutes, more on a small server |
| The next ones | Your own code and whatever dependency changed |
| Time limit | One hour for each build step. `sudo cipi app deploy-config blog --build-timeout=…` changes it |
| Memory | Linking a release binary needs RAM. Under about 4 GB of RAM and swap together, add swap first: Cipi says so when it installs Rust |
| Disk | The build cache grows to gigabytes. `sudo cipi rust clean blog` removes it; the next deploy compiles from the start |

## Commands of the app

The commands of a Laravel Rust app are compiled into its binary. Run them from the release being served:

```bash
# As root
$ sudo cipi app artisan blog migrate:status
$ sudo cipi app artisan blog route:list

# As the app's user
$ sudo su - blog
$ laravel queue:failed
$ laravel key:generate --show
```

`laravel` is a shell function for the app's user: it runs `~/current/bin/app` from `~/current`, where the `.env` is.

## Queue worker and scheduler

| | What runs | Turn it on or off |
| --- | --- | --- |
| Queue worker | `bin/app queue:work` under Supervisor, in the live release | `sudo cipi app edit blog --queue=on\|off` |
| Scheduler | `bin/app schedule:run`, every minute from the app's crontab | `sudo cipi app edit blog --scheduler=on\|off` |

The worker is restarted on the new release after every deploy, once Nginx has moved. Its log is `~/logs/queue.log`. [`sudo cipi worker`](https://cipi.sh/docs/workers) is for Laravel's PHP workers and Symfony's Messenger, and refuses a Laravel Rust app.

## Inertia server-side rendering

With SSR on, a Node process beside the app renders the first page on the server. Cipi runs it for you, in the release that is serving.

```bash
$ sudo cipi app edit blog --ssr=on      # or --ssr at create
$ sudo cipi deploy blog
```

| What changes | |
| --- | --- |
| The `.env` | `INERTIA_SSR=true` |
| The frontend build | `npm run build:ssr`, which also writes `bootstrap/ssr/app.js`. A build command of your own is left as it is: it has to write that file |
| A new program | `node bootstrap/ssr/app.js` under Supervisor, on the app's Node version, restarted on each new release |
| Its log | `~/logs/ssr.log` |

A deploy that finds no bundle says so: without it Laravel renders every page in the browser, with no error.

> [!WARNING]
> **One app per server.** Laravel Rust reaches the SSR process on `127.0.0.1:13714` and has no setting for another port. A second app asking for SSR is refused, with the name of the one that has it.

## Reverb

Laravel Rust has a Reverb WebSocket server in its binary. Cipi can run it beside the app, with the same command a Laravel app uses:

```bash
$ sudo cipi app reverb enable blog
$ sudo cipi deploy blog
$ sudo cipi app reverb status blog
$ sudo cipi app reverb disable blog
```

| What `enable` does | |
| --- | --- |
| `Cargo.toml` | Nothing: add the `reverb` feature of `laravel-rust` yourself, and commit |
| The `.env` | `BROADCAST_CONNECTION=reverb`, `REVERB_APP_ID`, `REVERB_APP_KEY`, `REVERB_APP_SECRET`, the public host, port and scheme. They follow the certificate and the domain |
| A new program | `bin/app reverb:start` on a localhost port, started by the next deploy |
| Nginx | `/app` and `/apps` of the app's domain go to it, WebSocket upgrades included |
| Its log | `~/logs/reverb.log` |

> [!WARNING]
> Laravel documents this server as **one for local development**: a single process, with connections and channels kept in memory. On one server with a moderate number of clients it does the job. Every deploy and every restart drops the open connections; Laravel Echo reconnects. For more than that, point `REVERB_*` in the `.env` at another Reverb server.

## Status, restart, logs

```bash
$ sudo cipi node status blog      # the two slots, the worker, SSR, Reverb
$ sudo cipi node restart blog     # zero-downtime restart
$ sudo cipi node logs blog        # what the server wrote to stderr
```

A Laravel Rust app shares the blue/green machinery of [Node server apps](https://cipi.sh/docs/node-apps#blue-green), which is why these commands start with `node`.

## The toolchain

One stable Rust for the server, in `/opt/cipi/rust`, installed by rustup (Rust's official installer, checked against its published checksum). Apps build with it as their own user; none can change it.

```bash
$ sudo cipi rust status           # version, pinned toolchains, the apps
$ sudo cipi rust update           # the latest stable
$ sudo cipi rust clean blog       # remove one app's build cache
$ sudo cipi rust prune            # remove pinned toolchains no app uses
$ sudo cipi rust remove           # only when no app uses it
```

After an update the apps keep running the binary they have. Each is rebuilt, from the start, by its next deploy.

### A toolchain of the app's own

A `rust-toolchain.toml` in the repository is followed. The deploy reads its `channel`, installs that toolchain beside the server's stable the first time, and builds the app with it.

```toml
# rust-toolchain.toml
[toolchain]
channel = "1.99.0"
```

| | |
| --- | --- |
| Channels | `stable`, `beta`, `nightly`, a version (`1.99` or `1.99.0`), a dated nightly (`nightly-2026-11-30`) |
| Anything else | The deploy stops and says which channels it takes |
| `components`, `targets`, `path` | Not used: a toolchain is installed with `rustc`, `cargo` and the standard library |
| How many | Six beside stable. `sudo cipi rust prune` removes the ones no app builds with any more |
| No file | The server's stable |

## Limits

| | |
| --- | --- |
| Inertia SSR | [One app per server](https://cipi.sh/docs/laravel-rust#ssr) |
| Reverb | The binary's own server, which Laravel calls [a development one](https://cipi.sh/docs/laravel-rust#reverb) |
| `rust-toolchain.toml` | The channel is followed; components and targets are not installed |
| [Server sync](https://cipi.sh/docs/sync) | Laravel Rust apps are moved like the others. On the new server Reverb is turned on again by hand, and the first deploy compiles every crate |

## Common problems

| Problem | Fix |
| --- | --- |
| The deploy ends at *not a valid object name: main* | The repository has no `main`: Laravel's skeleton has `0.x` alone. `sudo cipi app edit blog --branch=0.x`, then deploy. An app created without `--branch` [takes the repository's default](https://cipi.sh/docs/create-app#branch) by itself |
| `502 Bad Gateway` right after creating the app | No release yet: the first successful deploy starts the app. After that, `sudo cipi node status blog` shows the two slots |
| The deploy stops at `rust:driver` | The app's database has no driver in the binary, and Cipi [could not add it to the build](https://cipi.sh/docs/laravel-rust#database): the message says why. Add the feature it names to `Cargo.toml`, or [move the app to PostgreSQL](https://cipi.sh/docs/laravel-rust#database-move). On a server that has not been updated, every missing driver stops there: `sudo cipi self-update`, then deploy again |
| *database connection `postgres` uses an unsupported or disabled driver* | A binary built without the driver of `DATABASE_URL`: `postgres` is the name of the connection, not the engine. A deploy adds the driver by itself; this is a server that has not been updated (`sudo cipi self-update`) or a `deploy.php` edited by hand. See [the database](https://cipi.sh/docs/laravel-rust#database) |
| `Permission denied (publickey)` while cloning | The repository does not have the app's deploy key: `sudo cipi deploy blog --key` shows it, to add as a read-only deploy key. A public repository needs none when given by its `https://` address: `sudo cipi app edit blog --repository=https://github.com/you/blog.git` |
| `400 Bad Request` on an alias | Laravel answers for `APP_URL`'s host only: list the others with `trust_hosts` |
| URLs start with `http://` | `trust_proxies(["127.0.0.1"])` is missing |
| The build is killed after minutes | The server ran out of memory while linking. Add swap, or build with fewer jobs: `jobs = 1` under `[build]` in `~/.cargo/config.toml` of the app's user |
| *requires rustc 1.xx or newer* | `sudo cipi rust update`, then deploy. With a `rust-toolchain.toml`, raise its `channel` |
| Pages are not rendered on the server | SSR needs `--ssr=on`, a build that writes `bootstrap/ssr/app.js`, and no other app holding port 13714: `sudo cipi node status blog` shows the `ssr` program |
| The Reverb program does not stay up | The `reverb` feature is missing in `Cargo.toml`: `~/logs/reverb.log` says the command is unknown |
| *Cargo.toml builds several binaries* | Set `default-run` in `Cargo.toml`, or `sudo cipi app edit blog --rust-bin=<name>` |
| The deploy times out during the first build | `sudo cipi app deploy-config blog --build-timeout=3600`, and deploy again: what was compiled is kept |

## Questions

| Question | Answer |
| --- | --- |
| Do I need PHP for a Rust app? | Not for the app. Cipi's deploy tool and the webhook receiver run on PHP, so the server keeps it. |
| Can it share a server with PHP apps? | Yes: it is one more isolated app, with its own Linux user and its own two ports on localhost. |
| Can I build elsewhere and upload the binary? | Not with this type: the build is part of the deploy. |
| Where are the static files served from? | By the app itself, from `public/` of the release. Nginx proxies every request to it. |
| SQLite? | Yes: `DATABASE_URL=sqlite://storage/app/database.sqlite?mode=rwc` keeps it in `shared/storage`, with the `database-sqlite` feature. Create the app with `--no-db`. |
| Step by step? | [Deploy Laravel Rust on your own VPS](https://cipi.sh/guides/deploy-laravel-rust). |

---

Index of every page: https://cipi.sh/llms.txt · Everything in one file: https://cipi.sh/llms-full.txt · Source: https://github.com/cipi-sh/cipi (MIT)
