# RustPress

# Docs

URL: https://rustpress.witsberry.com/docs/

> Official RustPress 0.1.4 documentation: install and host a site, move from WordPress, and build themes and plugins in any language with AI agents.

This is the RustPress documentation, up to date for **RustPress 0.1.5**. Everything you need to install, host, build on and run a site is on these pages.

RustPress is a fast, AI-native publishing core written in Rust: posts and pages, the template hierarchy, hooks (actions and filters), roles and capabilities, a REST API and admin screens. Plugins can be written in any language (JavaScript, WebAssembly, PHP, Python or any HTTP service), and AI agents built into the admin build themes, plugins and content behind approvals. The database layout is WordPress’s own, so an existing WordPress database can be used as it is.

## Start

*   [What’s new](/whats-new/): every release, newest first. 0.1.5 keeps the page cache full on Tailwind themes; 0.1.4 brought plugins that do what WordPress plugins do.
*   [Getting started](/getting-started/): install `rp`, start a site and finish the setup wizard.
*   [Install and update](/install-and-update/): downloads for every platform, databases, signed updates without downtime, building from source.
*   [Moving from WordPress](/moving-from-wordpress/): import a WordPress export or run on your existing WordPress database.

## Build

*   [Themes](/themes/): templates, the template hierarchy, child themes, theme options, Tailwind and converting WordPress themes.
*   [Plugins](/plugins/): runtimes, a first plugin in PHP or JavaScript, permissions, scope and the SDKs.
*   [Plugin API reference](/plugin-api/): meta boxes, roles, rewrite rules, blocks, WP\_Query, \$wpdb, HTTP calls, private files and hooks between plugins.
*   [Background jobs](/background-jobs/): scheduled events and plugin jobs with retries, no cron needed.
*   [AI agents](/ai-agents/): the agents in the admin that build themes, plugins and content behind approvals.
*   [MCP and AI tools](/mcp-and-ai-tools/): your site as an MCP server, plugin AI tools, other services’ tools and AI connections.
*   [Headless and REST API](/headless-and-rest-api/): a WordPress-shaped API, signed webhooks and draft previews.

## Run

*   [Hosting](/hosting/): a Linux server with HTTPS, Docker, Render, Railway, Fly.io, shared hosting, Windows and macOS.
*   [Running a site](/running-a-site/): email, logs, backups, cleanup, the security checklist and troubleshooting.
*   [Configuration](/configuration/): every setting and environment variable.
*   [Performance](/performance/): the page cache, a CDN, Redis, Valkey or Memcached, and keeping plugins out of the way.
*   [Safety and limits](/safety-and-limits/): security, plugin permissions, rollbacks, safe mode and what RustPress does not do yet.
*   [Command reference](/command-reference/): every `rp` command, grouped by task.

## Using these docs with AI

Every page here is also served as Markdown for AI tools: [/llms.txt](/llms.txt) is the index, [/llms-full.txt](/llms-full.txt) has every page in one file, and [/skills/rustpress/SKILL.md](/skills/rustpress/SKILL.md) is a ready-made skill for Claude Code and other agents. They are generated from these pages, so they are always current.

## Source code

RustPress is open source under the GPL (version 2 or later), like WordPress. The code, release notes and issue tracker are on [GitHub](https://github.com/Witsberry/RustPress), for anything newer than these pages.

---

# Getting started

URL: https://rustpress.witsberry.com/getting-started/

> Install rp with one command, start a site on SQLite, finish the setup wizard and find your way around the RustPress admin and site folder.

This page takes you from nothing to a running RustPress site: install the `rp` program, start a site, finish the setup wizard and find the admin.

## Install rp

On Linux (any distribution) or macOS, run:

```
curl -fsSL https://raw.githubusercontent.com/Witsberry/RustPress/main/install.sh | sh
```

The installer checks the download’s checksum and the release signature before it installs `rp`. You can also download a build for Linux, macOS or Windows from the [Releases page](https://github.com/Witsberry/RustPress/releases).

`rp` is one self-contained program. You do not need Rust, PHP, a web server or a database server.

## Start a site

```
rp serve --root mysite
```

`rp serve` prints an address like `http://127.0.0.1:8080/rp-admin/install?key=…`. Open it in your browser.

## Finish the setup wizard

The wizard asks for two things:

*   **A database.** SQLite needs no setup. You can also use MySQL, MariaDB, PostgreSQL or an existing WordPress database.
*   **Your admin account.**

The `key` in the printed address is a one-time setup key. It makes sure nobody else sets the site up before you do.

Prefer the shell? `rp install --url … --title … --user … --password … --email …` runs the same install without the browser.

## Where your files live

Each site has a site folder. `rp` uses the folder given with `--root`, then `$RP_ROOT`, then the current folder. It holds:

*   `rp-config.toml`: the site’s settings, created on first run with fresh secret keys.
*   `rp-content/`: themes, plugins, uploads and the AI workspace.
*   `sdk/`: the plugin SDKs.

## Admin and site addresses

| Address                                    | What it is                                                                                                                 |
| ------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------- |
| `/rp-admin/`                               | The admin, with clean names such as `/rp-admin/themes`, `/rp-admin/posts`, `/rp-admin/settings/reading` and `/rp-admin/ai` |
| `/rp-login`                                | Log in                                                                                                                     |
| `/rp-json/`                                | REST API with standard `wp/v2` shapes; `/wp-json/` also answers                                                            |
| `/rp-content/…`                            | Files; `/wp-content/…` links in old content still resolve                                                                  |
| `/sitemap.xml`, `/rp-comments`, `/rp-cron` | Sitemap, comment posting and scheduled tasks                                                                               |

Old `/wp-admin/*.php` and `/wp-login.php` links redirect to their RustPress equivalents.

## Next steps

*   Coming from WordPress? Read [Moving from WordPress](/moving-from-wordpress/).
*   Choose a database or host: [Install and update](/install-and-update/).
*   Change the look of your site: [Themes](/themes/).
*   See every command: [Command reference](/command-reference/).

---

# Install and update

URL: https://rustpress.witsberry.com/install-and-update/

> Download RustPress for Linux, macOS or Windows, pick SQLite, MySQL, MariaDB or PostgreSQL, and update with signed releases and zero downtime.

This page covers installing RustPress, choosing a database, updating and building from source. For a first run, start with [Getting started](/getting-started/); to put a site online, see [Hosting](/hosting/).

## One command on Linux or macOS

```
curl -fsSL https://raw.githubusercontent.com/Witsberry/RustPress/main/install.sh | sh
```

The installer picks the right build, checks it against the release checksums and the RustPress release signature, and installs `rp` into `/usr/local/bin` (asking for sudo), or `~/.local/bin` when that isn’t possible. `RP_VERSION=0.1.4` installs a given version and `RP_INSTALL_DIR=/opt/rustpress/bin` another folder. Prefer to read it first? Download [install.sh](https://github.com/Witsberry/RustPress/blob/main/install.sh), look, then run `sh install.sh`.

## Or download it

Get the file for your system from the [releases page](https://github.com/Witsberry/RustPress/releases). It is one self-contained program: no Rust, PHP, web server or database server needed.

| System                                                | File                             |
| ----------------------------------------------------- | -------------------------------- |
| Linux, Intel/AMD (any distribution, including Alpine) | `rustpress-…-linux-x64.tar.gz`   |
| Linux, ARM (Raspberry Pi 4/5, AWS Graviton, Ampere)   | `rustpress-…-linux-arm64.tar.gz` |
| macOS, Apple Silicon                                  | `rustpress-…-macos-arm64.tar.gz` |
| macOS, Intel                                          | `rustpress-…-macos-x64.tar.gz`   |
| Windows 10/11, Windows Server                         | `rustpress-…-windows-x64.zip`    |

The Linux builds are fully static and run on any distribution. Check a download against `SHA256SUMS.txt` from the same release with `sha256sum -c SHA256SUMS.txt --ignore-missing` (Linux) or `shasum -a 256 -c SHA256SUMS.txt --ignore-missing` (macOS).

**macOS:** the program isn’t signed by Apple yet, so macOS blocks it the first time. Allow it once with `xattr -d com.apple.quarantine ./rp`, or under *System Settings › Privacy \& Security › Open Anyway*.

## Databases

The setup wizard asks for a database, or set `database_url` in `rp-config.toml` (or `$RP_DATABASE_URL`):

| Database         | Example database\_url                               |
| ---------------- | --------------------------------------------------- |
| SQLite (default) | `sqlite://rp-content/database.sqlite`               |
| MySQL            | `mysql://user:password@127.0.0.1:3306/wordpress`    |
| MariaDB          | `mariadb://user:password@127.0.0.1:3306/wordpress`  |
| PostgreSQL       | `postgres://user:password@127.0.0.1:5432/wordpress` |

All four are tested with the same 76 end-to-end checks (SQLite, MySQL 8.0, MariaDB 11.8, PostgreSQL 16), plus a two-way test against a database installed by PHP WordPress.

*   New sites use the table prefix `rp_`. To run on an existing WordPress database, set `table_prefix` to `wp_` (or that site’s prefix).
*   On MySQL and MariaDB, tables use WordPress’s own layout, so WordPress password hashes verify, PHP-serialized roles and options are read, and values are written back so PHP WordPress keeps reading the database too.
*   Managed databases connect over TLS. Every setting is in [Configuration](/configuration/).

## Updating

RustPress checks for new releases twice a day (turn that off with `check_updates = false`). When one is out, the Dashboard shows a notice and **Dashboard › Updates** has an *Update* button. From the shell:

```
rp update --check   # is there a newer version?
sudo rp update      # install it (sudo only if the program file belongs to root)
rp version          # what's running
```

What an update does:

1.  Downloads the release for this system and checks it against the release’s `SHA256SUMS.txt`, whose Ed25519 signature must match the release key built into `rp`. An unsigned release, a bad signature or a mismatched file is refused.
2.  Test-runs the new program; if it doesn’t start on this machine, nothing changes.
3.  Keeps the current program as `rp.previous`, then puts the new one in its place.
4.  Tells every running server started from that file to switch over. Each lets AI agents finish their current run, stops taking new connections, finishes requests in progress (up to 30 seconds), and starts the new version on the same socket and process ID. New visitors wait a moment instead of getting an error: no request is refused or dropped.

Database changes a release needs are applied when it starts. Back up first for big updates (see [Running a site](/running-a-site/)). Versions before 0.1.1: replace the `rp` program and restart once.

### Going back

```
sudo cp /opt/rustpress/rp.previous /opt/rustpress/rp && sudo systemctl reload rustpress
```

**Servers without internet access:** download the release elsewhere, copy `rp` over the old program, then reload, or send the server `SIGUSR2` (`kill -USR2 $(cat /srv/mysite/rp.pid)`). `RP_UPDATE_API` and `RP_UPDATE_REPO` point update checks at a mirror.

## Building from source

```
# Standard release build: target/release/rp
cargo build --release

# Smaller build with LTO, stripped
cargo build --profile dist

# Static Linux build (install cargo-zigbuild with: pip install cargo-zigbuild)
cargo zigbuild --profile dist --target x86_64-unknown-linux-musl
```

Pushing a `v*` tag builds every platform on GitHub Actions and signs `SHA256SUMS.txt` with the release key; without the key the release fails rather than publish unsigned files. `npm run build` compiles the server and exports a static demo to `dist/`.

---

# Command reference

URL: https://rustpress.witsberry.com/command-reference/

> Every rp command in one place: serve, update, import, export, themes, plugins, database, cache, cron, users, MCP and shared hosting setup.

This page lists every `rp` command, grouped by task. Every command takes `--root DIR`, the site folder; without it, `$RP_ROOT` or the current folder is used. `rp help` prints them all.

## Site

| Command                                                        | What it does                                                                    |
| -------------------------------------------------------------- | ------------------------------------------------------------------------------- |
| `rp serve [--listen ADDR] [--safe-mode]`                       | Run the site: front end, `/rp-admin/`, `/rp-login`, `/rp-json/`                 |
| `rp install --url … --title … --user … --password … --email …` | Install without the browser                                                     |
| `rp update [--check]`                                          | Install the latest signed release; running servers switch over without downtime |
| `rp version`                                                   | Show the installed version                                                      |
| `rp option get NAME` / `rp option set NAME VALUE`              | Read or change a setting                                                        |
| `rp export DIR`                                                | Write the public site as static HTML (needs pretty permalinks)                  |
| `rp demo DIR`                                                  | Build a throwaway demo site and export it                                       |
| `rp help`                                                      | List every command                                                              |

## Shared hosting

| Command                               | What it does                                                           |
| ------------------------------------- | ---------------------------------------------------------------------- |
| `rp cgi [--fcgi-listen ADDR]`         | Run under a web server as FastCGI or CGI (picked by itself)            |
| `rp cgi-setup --public DIR [--force]` | Write the start scripts and `.htaccess`, and print the cron job to add |

Steps are in [Hosting](/hosting/).

## Content

| Command                                                                                               | What it does                                                        |
| ----------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------- |
| `rp import FILE.xml [--author LOGIN] [--create-users] [--no-attachments] [--allow-local-attachments]` | Import a WordPress export file; attachments go to the Media Library |
| `rp export-content [FILE.xml] [--content post\|page\|all]`                                            | Write a WordPress export file                                       |
| `rp media regenerate`                                                                                 | Rebuild image sizes                                                 |

## Themes and plugins

| Command                                                          | What it does                                                |
| ---------------------------------------------------------------- | ----------------------------------------------------------- |
| `rp theme list`                                                  | List installed themes                                       |
| `rp theme activate SLUG`                                         | Activate a theme                                            |
| `rp theme build`                                                 | Compile the theme’s Tailwind CSS                            |
| `rp theme export SLUG`                                           | Export a theme as a zip                                     |
| `rp theme install FILE.zip [--replace] [--activate] [--convert]` | Install a theme; `--convert` converts a WordPress theme zip |
| `rp plugin list`                                                 | List installed plugins                                      |
| `rp plugin activate SLUG` / `deactivate SLUG`                    | Turn a plugin on or off (its requirements are checked)      |
| `rp plugin export SLUG`                                          | Export a plugin as a zip                                    |
| `rp plugin install FILE.zip [--replace] [--activate]`            | Install a plugin                                            |
| `rp plugin build DIR`                                            | Compile a Rust plugin to WebAssembly, in a sandbox          |
| `rp backup [FILE]`                                               | Save every theme and plugin in one zip                      |

## Database and cache

| Command                             | What it does                                                                                                                       |
| ----------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| `rp db schema`                      | Show the database tables and who owns them                                                                                         |
| `rp db optimize [--revisions N]`    | Clean and compact the database (also runs weekly)                                                                                  |
| `rp db leftovers`                   | List data left by removed plugins                                                                                                  |
| `rp db plugin-data SLUG [--remove]` | Show a plugin’s data, or remove it                                                                                                 |
| `rp cache status`                   | Check the cache server (Redis, Valkey, Memcached)                                                                                  |
| `rp cache flush`                    | Clear every cache: pages on all servers, plugins’ cached data, templates and Cloudflare. Also **Clear cache** in the admin toolbar |

## Users and AI

| Command                                                   | What it does                                                                                      |
| --------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| `rp user create LOGIN EMAIL PASSWORD [ROLE]`              | Create a user                                                                                     |
| `rp user app-password LOGIN NAME`                         | Create an application password for an API client or AI app                                        |
| `rp mcp --user ID [--abilities site,content,code,deploy]` | Serve the site’s AI tools as an MCP server over stdio (also over HTTP at `/rp-json/rp/v1/ai/mcp`) |

More on connecting AI apps: [MCP and AI tools](/mcp-and-ai-tools/).

## Maintenance

| Command                  | What it does                                                                                        |
| ------------------------ | --------------------------------------------------------------------------------------------------- |
| `rp cron list`           | Scheduled events and background job counts                                                          |
| `rp cron run`            | Run due scheduled tasks, background jobs, cleanup and the update check once (for a system cron job) |
| `rp cleanup [--dry-run]` | Clear stale AI workspace files, old rollback copies, trash and logs (also runs daily)               |

Settings and environment variables are in [Configuration](/configuration/).

---

# Moving from WordPress

URL: https://rustpress.witsberry.com/moving-from-wordpress/

> Move a WordPress site to RustPress: run on your existing database with users and passwords, or import an export file with media, menus and comments.

This page explains the two ways to move a WordPress site to RustPress, what comes across, and what happens to themes and plugins.

## Two paths

| Path                            | How                                                           | Good for                                               |
| ------------------------------- | ------------------------------------------------------------- | ------------------------------------------------------ |
| Import a WordPress export (WXR) | Export from WordPress, import the .xml or .zip into RustPress | A fresh RustPress site on any database                 |
| Run on the WordPress database   | Point RustPress at your WordPress MySQL or MariaDB database   | Keeping everything as is, users and passwords included |

## Path 1: Import a WordPress export

1.  In WordPress, go to **Tools › Export** and choose **All content**.
2.  In RustPress, go to **Tools › Import** and upload the .xml (or .zip) file.

The import runs in the background with a progress bar. Running it again skips what is already there.

### What comes across

*   Posts, pages and custom post types
*   Comments
*   Categories and tags
*   Custom fields
*   Featured images
*   Menus
*   Authors

Attachments are downloaded into the Media Library with thumbnails, and links in your content are updated to point at them.

### Import from the shell

```
rp import export.xml [--author LOGIN] [--create-users] [--no-attachments] [--allow-local-attachments]
```

*   `--author LOGIN`: assign imported content to this user.
*   `--create-users`: create users for the authors in the file.
*   `--no-attachments`: skip downloading attachments.
*   `--allow-local-attachments`: allow downloads when the old site is on this computer or local network. Without it, attachments are only downloaded from public addresses.

## Path 2: Run on your WordPress database

Point RustPress at your WordPress MySQL or MariaDB database, either in the setup wizard or by setting `database_url` and `table_prefix` in `rp-config.toml`:

```
database_url = "mysql://user:password@127.0.0.1:3306/wordpress"
table_prefix = "wp_"
```

The site runs as is, users and passwords included. Menus and widgets are stored exactly like WordPress stores them.

### Passwords

WordPress password hashes (\$wp\$ bcrypt, phpass and md5) verify, so your users log in with their existing passwords.

### Going back to PHP WordPress

The move works both ways. RustPress reads PHP-serialized roles and options and writes structured values back PHP-serialized, so PHP WordPress keeps reading the same database. This is covered by a two-way test against a database installed by PHP WordPress.

## Themes

Upload a WordPress theme zip under **Appearance › Add New Theme**, or use `rp theme install FILE.zip --convert`.

*   **Block themes convert fully:** theme.json styles and fonts, templates, parts, patterns, query loops and navigation.
*   **Classic PHP themes** keep their stylesheet and assets on starter templates.

Each conversion writes a `CONVERSION.md` file listing what was left out. You can also let the WordPress Migrator agent rebuild the theme. See [Themes](/themes/) for details.

## Plugins

*   Classic PHP plugins that stick to common WordPress functions run through the PHP SDK.
*   For other plugins, upload the zip in the AI chat and an agent rebuilds it natively. See [AI agents](/ai-agents/) and [Plugins](/plugins/).

## What does not run

Large plugins built on WordPress internals, such as WooCommerce, Yoast and Elementor, install but will not activate. The installer tells you when this is the case. For more on limits, see [Safety and limits](/safety-and-limits/).

---

# Themes

URL: https://rustpress.witsberry.com/themes/

> Build RustPress themes with Jinja-style templates, the WordPress template hierarchy, Tailwind v4 and live theme options, or convert a WordPress theme.

This page explains how RustPress themes are built, customised, converted from WordPress, exported and installed.

## What a theme is

A RustPress theme is a folder with a `style.css` header, like a WordPress theme, and Jinja-style HTML templates instead of PHP files. `templates/index.html` is required. Shared pieces such as headers and footers go in `parts/`, and `parts/base.html` with a `{% block main %}` is the layout plugins’ templates wrap.

```
/*
Theme Name: My Theme
Version: 1.0.0
Template: twentyrust            (optional: makes this a child theme)
Requires Plugins: shop-core     (optional)
Requires RustPress: 0.1.4       (optional)
*/
```

## Templates

Templates use MiniJinja syntax:

*   `{{ }}` prints a value.
*   `{% if %}` and `{% for %}` handle conditions and loops.
*   `{% extends %}`, `{% block %}` and `{% include %}` share layout between templates.

Templates get the site (name, address, logo, icon), the navigation, the current post or list of posts, pagination, archive details, comments and the theme’s options. Print the core’s hooks: `{{ wp_head|safe }}` in `<head>`, `{{ admin_bar|safe }}` and `{{ wp_body_open|safe }}` after `<body>`, and `{{ wp_footer|safe }}` before `</body>`.

## Template hierarchy

RustPress picks a template the WordPress way, from most specific to least specific:

| View                       | Templates                                                     |
| -------------------------- | ------------------------------------------------------------- |
| Front page                 | `front-page`                                                  |
| Blog home                  | `home`                                                        |
| Single post or custom type | `single-{type}-{slug}`, `single-{type}`, `single`, `singular` |
| Page                       | `page-{slug}`, `page-{id}`, `page`, `singular`                |
| Category                   | `category-{slug}`, `category`                                 |
| Tag                        | `tag-{slug}`, `tag`                                           |
| Custom taxonomy            | `taxonomy-{tax}-{term}`, `taxonomy`                           |
| Author                     | `author`                                                      |
| Date                       | `date`                                                        |
| Post type archive          | `archive-{type}`, `archive`                                   |
| Search results             | `search`                                                      |
| Not found                  | `404`                                                         |
| Fallback for everything    | `index`                                                       |

Plugins may ship templates for their own content types (`single-product.html`, `archive-product.html`). A theme overrides one by shipping a file with the same name.

## SEO, icons and the logo come from the core

Since 0.1.4, `{{ wp_head }}` prints the description, robots, canonical link, Open Graph and X cards and JSON-LD (**Settings › SEO**), plus the favicon, Apple touch icon and web manifest made from the site icon (**Settings › General**). Themes add none of these. Use `site.logo` for the header logo, with the site name as alt text and fallback. Use one `h1` per page, headings in order, real links and buttons, and `<main>`, `<nav>` and `<article>`, so search engines, screen readers and AI agents read the page right.

## Child themes

Child themes change only what they contain, so you can change a theme without editing it. The bundled Twenty Rust theme comes with a dark child theme you can use as an example.

## Theme options and the live customizer

A theme declares its settings in `theme-options.json`: text, colours, Media Library images, links, pages, selects and repeaters. Site owners change them under **Appearance › Theme Options**, and changes preview live before saving. Templates read them as `options.<id>`; colours and numbers are also CSS variables (`--opt-<id>`).

## Tailwind v4 and assets

Themes can use Tailwind v4, compiled ahead of time with `rp theme build`; the standalone Tailwind tool is downloaded and checked once. Link scripts and styles by their plain names (`{{ theme_url }}css/app.css`): RustPress serves them under content-hashed names cached for a year and renamed the moment the file changes, so never add `?ver=` or other cache-busting.

## Editing theme files

The file editors for themes and plugins check syntax and undo a change automatically if it breaks the site. Set `disallow_file_edit = true` to turn them off on production.

## Building themes with AI agents

The Theme Designer and Site Builder agents build option-driven Tailwind themes in a workspace, preview them privately in a sandbox, and propose the install for your approval. See [AI agents](/ai-agents/).

## Converting WordPress themes

Upload a WordPress theme zip under **Appearance › Add New Theme**, or run `rp theme install FILE.zip --convert`.

*   **Block themes convert fully:** theme.json styles and fonts, templates, parts, patterns, query loops and navigation.
*   **Classic PHP themes** keep their stylesheet and assets on starter templates.

Each conversion writes `CONVERSION.md`, listing what was left out. An agent can refine the rest, or the WordPress Migrator agent can rebuild the theme. More in [Moving from WordPress](/moving-from-wordpress/).

## Exporting and installing themes

```
rp theme export SLUG                                   # one theme as a zip
rp backup                                              # every theme and plugin in one zip
rp theme install FILE.zip [--replace] [--activate] [--convert]
```

The Themes screen has **Export** on each theme and **Export all**, and **AI › Changes** downloads workspace projects. A theme that requires a plugin isn’t activated until that plugin is active.

## Twenty Rust

RustPress ships with the Twenty Rust theme and its dark child theme. They are a working starting point for your own theme. All theme commands are in the [Command reference](/command-reference/).

---

# Plugins

URL: https://rustpress.witsberry.com/plugins/

> Write RustPress plugins in JavaScript, WebAssembly, PHP, Python or any HTTP service, with sandboxing, permissions, dependencies and plugin tables.

This page explains how RustPress plugins work, which languages you can write them in, how to install them, and how to keep them fast and safe. For every API in detail, see the [Plugin API reference](/plugin-api/).

## What plugins can do

Since 0.1.4, plugins can do what WordPress plugins do, in all four SDKs: filters, actions and shortcodes; REST routes and public addresses; custom content types and taxonomies; custom fields and meta boxes; roles and capabilities; rewrite rules; admin menus and settings pages; editor blocks; scripts and styles; `WP_Query` and `$wpdb`; their own tables; background jobs; private files; calls to other websites; dashboard widgets; and AI tools for the site’s agents. Plugins can also depend on each other and extend each other through hooks.

## One protocol for every language

A plugin is a folder in `rp-content/plugins/`. Every runtime speaks the same JSON protocol, documented in `sdk/PROTOCOL.md`. The core sends a message with `kind`, `hook`, `args` and `context`, and the plugin answers with `result`, `output` and `error`.

```
core   → plugin   {"kind", "hook", "args", "context"}
plugin → core     {"result", "output", "error"}
```

## Runtimes

| Runtime | How it runs                                                                                                     | Good for                                                             |
| ------- | --------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------- |
| `js`    | JavaScript inside the core (QuickJS compiled to WebAssembly, the same sandbox as `wasm`). Nothing to install.   | Most plugins: filters, shortcodes, blocks, REST routes, admin pages. |
| `wasm`  | WebAssembly module inside the core (wasmtime). Sandboxed, fuel-limited, a fresh instance per call.              | Rust, C, Zig, AssemblyScript, TinyGo.                                |
| `stdio` | A program started per request, JSON on stdin and stdout. PHP and Python plugins using the SDK are kept running. | PHP, Python, Node, Ruby, compiled binaries.                          |
| `http`  | A long-running service: an external URL, or a `serve` command the core starts.                                  | Busy plugins, any web stack.                                         |

## PHP plugins, the classic way

A PHP file with a `Plugin Name:` header needs no manifest. The PHP SDK is prepended to your code, so the familiar WordPress functions are there, including:

*   `add_filter`, `add_action`, `add_shortcode`, `do_action`, `apply_filters`
*   `register_rest_route`, `register_post_type`, `register_taxonomy`, `register_block_type`, `register_post_meta`
*   `add_menu_page`, `add_options_page`, `add_meta_box`, `wp_enqueue_script`, `wp_enqueue_style`
*   `get_option`, `update_option`, `get_posts`, `WP_Query`, `$wpdb` and `dbDelta`
*   `get_post_meta`, `update_post_meta`, user and term meta, `wp_remote_get` and `wp_remote_post`
*   Nonces, `esc_html` and the other escaping functions, transients and `wp_cache_*`
*   Action Scheduler’s `as_enqueue_async_action()` and `as_schedule_single_action()`
*   `WP_REST_Request`, `WP_REST_Response`, `WP_Error`

```
<?php
/**
 * Plugin Name: Thanks
 */
add_filter( 'the_content', function ( $content ) {
    return $content . '<p>Thanks for reading!</p>';
} );
```

Large plugins built deep on WordPress internals, such as WooCommerce, Yoast or Elementor, install but won’t activate; the installer says so. Upload the zip in the AI chat and an agent can rebuild one natively.

## Sandboxed JavaScript plugins

JavaScript plugins need nothing on the server, not even Node. Add a `plugin.json`:

```
{ "name": "Twice", "runtime": "js", "entry": "plugin.js" }
```

And a `plugin.js`:

```
const wp = require('rustpress')();
wp.addShortcode('twice', (atts) => String(Number(atts.n || 0) * 2));
wp.addFilter('the_content', async (html) => html + '<p>' + wp.esc(await wp.getOption('blogname')) + '</p>');
wp.run();
```

The same file runs under Node too. In the sandbox only the SDK can be required: there is no `fetch`, timers, files or `process` (use `wp.http()` with the `network` permission), and each call starts fresh, so keep data in options or tables.

## Other languages

Any program that reads and writes JSON can be a plugin. Point `plugin.json` at it and pick the runtime:

```
{ "name": "My Plugin", "runtime": "stdio", "entry": "main.py" }
```

## Installing plugins

Go to **Plugins › Add New Plugin** and upload a `.zip` or a single `.php` file. RustPress unpacks it safely and can activate it right away. You can also install over the REST API (`POST /rp-json/wp/v2/plugins`, multipart field `pluginzip`, `status=active`) or with `rp plugin install FILE.zip`. Set `disallow_file_mods = true` in `rp-config.toml` to turn installing and removing off.

## Dependencies

A plugin that needs another declares it, with an optional minimum version:

```
{ "requires": ["shop-core", "payments (>=1.2)"], "requires_rustpress": "0.1.4" }
```

In PHP, use the `Requires Plugins:` and `Requires RustPress:` headers. RustPress won’t activate a plugin until what it needs is active, and won’t let a required plugin be turned off from under it. Details in the [Plugin API reference](/plugin-api/).

## Permissions

A plugin declares what it needs with a `Permissions: content:read, options` header in PHP, or a `"permissions"` list in `plugin.json`:

| Permission      | Allows                                                                           |
| --------------- | -------------------------------------------------------------------------------- |
| `content:read`  | Reading drafts, private content and non-public types                             |
| `content:write` | Creating and changing content                                                    |
| `options`       | Settings other than the plugin’s own                                             |
| `users`         | Users, roles and capabilities                                                    |
| `site`          | Site-wide changes, such as granting `manage_options`                             |
| `network`       | Calling other websites; `"network": ["api.stripe.com"]` limits it to those hosts |

With permissions declared, a plugin gets only those, plus its own options, public settings and its own REST routes. Plugins that declare nothing keep full access and are labelled so. The full rules are in [Safety and limits](/safety-and-limits/).

## Scope: a plugin only runs where it is needed

A plugin is only called for the hooks, shortcodes and routes it registered, and filters and actions only run where they are needed. Declare the scope in `plugin.json` (areas, paths like `/shop/*`, content types, page kinds) or with `Load On:` headers in PHP. The site owner can override it under **Plugins › Where it runs**.

PHP plugins are kept running in the background on PHP’s built-in server with OPcache, so a call costs a couple of milliseconds instead of starting PHP each time. Python plugins that use the SDK’s `run()` are kept running the same way. `RP_PHP_PER_CALL=1` goes back to one process per call, and `php_binary` or `RP_PHP` picks the PHP program.

## SDKs and host calls

The `sdk/` folder beside `rp-config.toml` has SDKs for PHP, JavaScript (Node and the sandbox), Python and Rust (WebAssembly). Plugins talk back to the core with host calls, over HTTP with a token (`POST /rp-json/rp/v1/host`) or through the `wp.host_call` import in WebAssembly: options, REST requests, filters and actions, mail, scheduled events, the object cache, plugin tables, background jobs, private files, HTTP calls, meta, nonces and logging. Log with `wp.log(msg, 'error')`, `rp_log()` or `log()`; entries land in **Tools › Logs**.

## Plugin data

Plugins create their own tables without SQL (`wp.db.createTable('orders', {…})`, `rp_db_create_table(…)`), keep private files that are never served directly (`rp.files.put()`, `rp_file_put()`), and queue slow work as [background jobs](/background-jobs/). RustPress records what belongs to which plugin. When you remove a plugin, it asks whether to keep or delete its tables, settings, metadata named after it, scheduled tasks and private files.

## Public addresses

Plugins can answer at addresses on the site root: `rp_register_page('/sitemap.xml', $callback)` in PHP, `wp.registerPage(path, cb)` in JavaScript, with `{name}` segments and a trailing `*`. A plugin’s address replaces the core’s `/sitemap.xml` or `/robots.txt`. Core paths (`/rp-admin`, `/rp-json`, `/rp-content`, `/rp-login` and others) and addresses another plugin already holds are refused. Plugins can also add `wp_ajax_{action}` and `wp_ajax_nopriv_{action}` handlers.

## Bundled examples

These come installed and switched off, so you can read and try them:

*   **Hello PHP:** reading time, a `[hello]` shortcode, a footer note, an admin notice, a settings page and a REST route.
*   **WebAssembly Hello:** a hand-written WAT module.
*   **Word Stats:** Node.js over HTTP, calling the REST API back.
*   **Simple Books:** a custom post type and taxonomy in PHP.

`examples/plugins/reading-time-wasm` in the [repository](https://github.com/Witsberry/RustPress) is a Rust plugin.

## Building Rust plugins

`rp plugin build DIR` compiles a Rust plugin to `plugin.wasm`. AI agents do the same through `check_project`. It needs Rust, the `wasm32-unknown-unknown` target and bubblewrap (Linux) on the server.

*   The build runs in a bubblewrap sandbox that sees only the toolchain, the SDK and the build folder.
*   RustPress writes `Cargo.toml` itself. Dependencies are limited to the SDK, `serde`, `serde_json`, `once_cell` and `regex`.
*   `build.rs`, `include_str!`, `include_bytes!`, `env!` and `#[path]` are refused, checked with Rust’s own tokenizer.
*   Without the sandbox, nothing is built. You can also build on another computer and upload the zip with `plugin.wasm` included.

All plugin commands are in the [Command reference](/command-reference/). To let plugins give tools to AI agents, see [MCP and AI tools](/mcp-and-ai-tools/).

---

# AI agents

URL: https://rustpress.witsberry.com/ai-agents/

> AI agents in the RustPress admin build themes, plugins and content in a workspace. Every live change is a diff you approve, with rollback and an audit log.

This page explains the AI agents built into the RustPress admin: how to connect a provider, what agents can do, and the guard rails that keep a person in charge of every live change.

## What the AI menu does

The **AI** menu in the admin opens a chat where a team of agents builds themes, plugins and content for your site. Describe what you want in plain words. Upload a WordPress theme or plugin `.zip` and an agent studies it and rebuilds it natively. Attach a screenshot or a document and agents can work from it.

## Providers

Set providers up under **AI › Agents**:

*   Claude
*   OpenAI
*   Gemini
*   Any OpenAI-compatible endpoint, such as OpenRouter, Groq, or Ollama and LM Studio for local models
*   Claude Code installed on the server. It needs no API key and uses its own login.

API keys are stored encrypted with the site’s secret key and are never shown again. Each agent picks a model and an optional fallback model. What you type, and the site content an agent reads, goes to the provider you chose; use a local model if nothing may leave the server.

## Agents and abilities

Each agent gets a set of abilities: read the site, write content, build themes and plugins, review code, and propose installs. Agents can also, when you allow it:

*   Read web pages, for research or to study a design you point to
*   Use files you attach to the chat
*   Draw icons and images (share images, site icons, illustrations) and save them to the media library
*   Use tools from other services connected under **AI › External tools** (see [MCP and AI tools](/mcp-and-ai-tools/))

## Ready-made roles

RustPress comes with these agents ready to use: Site Builder, Theme Designer, Plugin Developer, Content Writer, Product Owner, Security Reviewer, QA Tester and WordPress Migrator. The Product Owner gathers requirements before anything is built: it asks you the questions that matter and writes acceptance criteria.

## Skills

Skills are instruction packs that agents load for a kind of work. Manage them under **AI › Skills**. Built in:

*   Design taste
*   Theme building (option-driven themes, no generic AI look)
*   Plugin building
*   Data access
*   Accessibility
*   SEO
*   Web performance
*   Copywriting
*   Responsive layout
*   WordPress migration
*   Secure plugins (an OWASP Top 10 checklist)
*   Memory safety

You can add your own, or download a `SKILL.md` from a URL. The SDK references and the plugin protocol are built in, so agents know every API in this release.

## The chat

The chat shows every step: the tools an agent calls, their results, hand-offs between teammates, and approval cards for changes. Replies stream as they are written, an activity line shows what the agent is doing, and opt-in browser notifications call you back when an agent needs you or finishes. From **Tools › Logs**, *Ask an agent* hands an error straight to an agent.

## Guard rails

### Who can run agents

*   Only administrators run agents.
*   An agent never has more rights than the person using it.
*   A teammate never gets writing abilities the asking agent lacks.

### Where agents can write

*   Agents write only in `rp-content/ai-workspace/<project>/`, with checked paths, text files only and size limits.
*   There is no tool for configuration, raw SQL, users, secrets or other plugins’ settings files.
*   The core is compiled Rust, so agents can’t edit it.

### Every live change is approved by a person

*   Anything that changes the live site (installing, activating, editing or publishing content) is a change a person approves after seeing the complete diff.
*   A project is frozen when it is proposed, so what gets installed is exactly what was shown.
*   Applying a change keeps a snapshot, so every change can be rolled back under **AI › Changes**, and the site rolls a change back by itself if pages start failing.

### Previews and builds are sandboxed

*   Workspace themes are previewed privately. Previews run in a sandbox, so scripts in an unapproved theme can’t act as the administrator.
*   Theme templates, Tailwind CSS and Rust plugin builds can’t read files outside the project or run code on the server. Rust builds run in bubblewrap.

### Content is data, not instructions

*   Uploaded files, posts, comments, logs, web pages, tool results and teammates’ reports are treated as data, never as instructions.
*   Agent drafts are HTML-filtered like those of any untrusted author.

### Audit, limits and bug reports

*   Every tool call goes to an audit log (`rp-content/ai/audit.log`, shown under **AI › Changes**).
*   A daily token limit stops runaway agents.
*   When an agent traces a problem to RustPress itself, it gives you a link to a pre-filled GitHub issue. Secrets, emails, the site address and server paths are masked, and nothing is sent until you submit it.

## Teamwork

### Teammates

Agents hand sub-tasks to each other with `ask_agent`, up to two levels deep and without loops. The Security Reviewer and QA Tester are read-only. When reviewers exist, builders must get their review before proposing an install.

### Questions

Agents ask you for a choice (with one option marked Recommended, such as which language a plugin should be written in), for information or for permission, then wait for your answer.

### Checks

`check_project` lints PHP, JavaScript, JSON and templates, builds Tailwind and Rust plugins, and scans for:

*   Remote code execution, XSS, injection, SSRF and open redirects
*   Weak randomness, XXE and unsafe deserialization
*   REST routes without permission checks
*   Hard-coded secrets
*   Memory-leak patterns
*   Missing permissions
*   Oversized files

Installs with errors or high findings can’t be proposed, and the Security Reviewer and QA Tester go through the OWASP Top 10 before one is.

### Logs and project docs

Agents read the site log with `read_logs` when something breaks and after previews. Every project carries a compressed `AGENTS.md` (files, hooks, data, permissions, decisions, changelog) kept up to date for the next agent or developer.

To use the same tools from Claude Desktop, Claude Code or your own AI app, see [MCP and AI tools](/mcp-and-ai-tools/). The full list of safeguards is in [Safety and limits](/safety-and-limits/).

---

# MCP and AI tools

URL: https://rustpress.witsberry.com/mcp-and-ai-tools/

> Use your RustPress site as an MCP server for Claude Desktop, Claude Code or any AI app, add plugin AI tools, and connect other services' MCP tools.

RustPress speaks MCP (Model Context Protocol) both ways. AI apps can work on your site through its guarded tools, plugins can add tools of their own, and the site’s agents can use tools from other services. This page covers all three.

## Your site as an MCP server

The tools the built-in [AI agents](/ai-agents/) use are also an MCP server, in two ways.

### stdio, on the server

```
rp mcp --user ID [--abilities site,content,code,deploy]
```

### HTTP, for AI apps anywhere

```
POST /rp-json/rp/v1/ai/mcp?abilities=content
```

Connect an AI app under **AI › Connections** with a scoped key or OAuth, or give a script an administrator’s application password:

```
rp user app-password LOGIN NAME
```

## Abilities

The `abilities` setting limits which tools a connection gets: `site`, `content`, `code` and `deploy`. Give a client only the abilities it needs. Changes to the live site still wait for approval, whoever asks.

## Plugins can register AI tools

Plugins add their own tools. A shop plugin registers `create_product`, and the site’s agents, Claude Desktop or your own AI app can fill the catalogue:

```
wp.registerAiTool('create_product', { description: 'Create a product as a draft', risk: 'draft',
  inputSchema: { type: 'object', properties: { title: { type: 'string' }, price: { type: 'number' } }, required: ['title'] } },
  async (a) => ({ id: (await wp.db.insert('products', { title: a.title, price: a.price })).id }));
```

*   In PHP, use `rp_register_ai_tool( $name, $args, $cb )`.
*   Tools are offered as `<plugin_slug>__<name>` (names use a-z, 0-9 and \_).
*   `ability` is `content` (default) or `site`.
*   The callback gets the input and `{ user, agent }`. Validate the input like any request, and return only what the agent needs: results go to an AI model.

## Risk levels

| Risk            | What happens                                                                                                        |
| --------------- | ------------------------------------------------------------------------------------------------------------------- |
| `read`          | Looks only. Runs at once.                                                                                           |
| `draft`         | Drafts or plugin data, nothing live. Runs at once.                                                                  |
| `ask` (default) | For anything that changes the live site. The call becomes a proposal that a person approves under **AI › Changes**. |

## Other services’ tools

Under **AI › External tools**, connect MCP servers from other services: HeyGen for video, design tools, automations or your own systems. Give the server’s address and sign in with OAuth (RustPress registers itself, with PKCE) or a key in a header. Their tools reach your agents as `mcp__<server>__<tool>`.

*   Every tool asks before it runs until you mark it “runs at once”, or turn it off.
*   You choose which agents may use each server.
*   Keys and tokens are stored encrypted, and only https servers on the public internet are reached.
*   Images a tool returns stay with the chat. Files it links to, such as a rendered video, go to the media library when an agent calls `save_media_from_url`, which only accepts addresses a tool returned or you gave.

## Owner controls

*   The owner can turn any plugin tool off under **AI › Agents › Tools from plugins**.
*   Plugins can’t call the AI API themselves.
*   Tool results are treated as data, not instructions.
*   Every call is audited.

## Command-line AI agents

Claude Code and other MCP clients reach the same guarded tools through `rp mcp`. CLI agents get none of the server’s environment.

*   **Claude Code:** supported. Chats started with Claude Code run with its built-in shell and file tools turned off, and without the server owner’s personal Claude Code setup.
*   **Gemini CLI:** works the same way, but Google replaced it with Antigravity CLI and it now only serves paid API keys. Use the Gemini API provider instead.
*   **Antigravity CLI:** not offered yet, because its built-in tools can’t be switched off when it runs headless.
*   **Codex CLI:** not offered, because it always keeps a shell that could read the site’s secrets. Use the OpenAI provider instead.

More on what agents may and may not do is in [Safety and limits](/safety-and-limits/).

---

# Headless and REST API

URL: https://rustpress.witsberry.com/headless-and-rest-api/

> Use RustPress headless with Next.js, Astro or SvelteKit: a WordPress-shaped REST API, application passwords, CORS, signed webhooks and draft previews.

This page explains the RustPress REST API and how to run RustPress headless, with your public site built in Next.js, Astro, SvelteKit or an app.

## The REST API

The API lives at `/rp-json/wp/v2/` and covers posts, pages, media, categories, tags, menus, comments, users, search and custom types. It uses WordPress’s shapes, so WordPress headless libraries work with it. That includes the same parameters and response fields, `_embed`, `_fields`, `_envelope` and the `X-WP-Total` header.

Public content needs no key. Drafts, private content and writing need an application password, kept on your front end’s server and never in the browser.

### Authentication

| Method                | How                                          |
| --------------------- | -------------------------------------------- |
| Cookie                | Logged-in cookie plus an `X-WP-Nonce` header |
| Application passwords | HTTP Basic                                   |
| Plugin tokens         | Bearer                                       |

## Headless mode

Turn it on under **Settings › Headless**. In headless mode:

*   The theme front end is off.
*   Visitors are redirected to the same address on your front end.
*   Permalinks, sitemaps and View links point to your front end.
*   Media stays on RustPress.

## CORS

List the exact origins that may call the API. Cross-origin requests carry no cookies.

## Webhooks

Changes to posts, pages, terms, menus, comments and settings are POSTed to your front end in batches, so it can rebuild only what changed. Each request is signed:

```
X-RP-Signature: sha256=HMAC_SHA256(secret, X-RP-Timestamp + "." + body)
```

A Next.js route that checks the signature and the timestamp, then revalidates the changed pages:

```
// app/api/revalidate/route.ts
import crypto from 'node:crypto';
import { revalidatePath } from 'next/cache';
export async function POST(req: Request) {
  const body = await req.text();
  const ts = req.headers.get('x-rp-timestamp') ?? '';
  const sig = req.headers.get('x-rp-signature') ?? '';
  const want = 'sha256=' + crypto.createHmac('sha256', process.env.RP_WEBHOOK_SECRET!).update(`${ts}.${body}`).digest('hex');
  const fresh = Math.abs(Date.now() / 1000 - Number(ts)) < 300;
  if (!fresh || sig.length !== want.length || !crypto.timingSafeEqual(Buffer.from(sig), Buffer.from(want))) {
    return new Response('bad signature', { status: 401 });
  }
  for (const e of JSON.parse(body).events) if (e.link) revalidatePath(new URL(e.link).pathname);
  revalidatePath('/');
  return Response.json({ ok: true });
}
```

## Previews

Preview on a draft opens `<front end>/api/preview?id=&type=&token=`. The token reads that one draft for 10 minutes:

```
GET /rp-json/wp/v2/<type>/<id>?preview_token=<token>
```

A Next.js preview route:

```
// app/api/preview/route.ts
import { draftMode } from 'next/headers';
import { redirect } from 'next/navigation';
export async function GET(req: Request) {
  const u = new URL(req.url);
  const [id, type, token] = ['id', 'type', 'token'].map((k) => u.searchParams.get(k));
  const r = await fetch(`${process.env.RP_API}/wp/v2/${type}/${id}?preview_token=${token}`, { cache: 'no-store' });
  if (!r.ok) return new Response('Preview link expired', { status: 401 });
  (await draftMode()).enable();
  redirect(`/preview/${type}/${id}?token=${token}`); // that page fetches the same URL
}
```

Plugins can add their own REST routes, see [Plugins](/plugins/). For caching on the RustPress side, see [Performance](/performance/).

---

# Performance

URL: https://rustpress.witsberry.com/performance/

> How RustPress serves pages in under a millisecond: a page cache that stays correct, Cloudflare purging, Redis, Valkey or Memcached, and compression.

This page explains what RustPress does to serve pages quickly, and the settings and hooks you can use to tune it. Most of it lives under **Settings › Speed**.

## Full-page cache

Pages for logged-out visitors are cached in memory and served in well under a millisecond. The cache empties itself the moment content, comments, users or public settings change, and entries expire after 10 minutes. Logged-in users, commenters and protected posts always get a fresh page. Responses carry an `X-Cache` header.

*   `rp option set rp_page_cache_ttl 300` changes the lifetime; `rp option set rp_page_cache 0` turns the cache off.
*   **Clear cache** in the admin toolbar, **Settings › Speed** or `rp cache flush` clears every cache: pages on all servers, plugins’ cached data, templates and Cloudflare.
*   Plugins opt a page out with `rp_page_cacheable`, vary it with `rp_page_cache_key`, change its lifetime with `rp_page_cache_ttl`, and purge a CDN on `rp_cache_purged`.

## A CDN in front (Cloudflare)

The page cache makes the server answer in under a millisecond, but a visitor far from the server still waits for the trip there and back, often 100 to 300 ms. Let a CDN keep pages near visitors: **Settings › Speed › Let the CDN keep pages for**, plus a Cloudflare zone ID and API token so every change purges Cloudflare’s cache, and the Cache Rule shown there to paste into Cloudflare. Public pages then carry `Cache-Control: public, max-age=0, s-maxage=…`; pages for logged-in people and commenters carry `private, no-store`.

## Redis, Valkey and Memcached

One server needs nothing: the cache lives in memory. With several servers behind a load balancer, or for a cache that survives restarts, point them all at one cache server, in **Settings › Speed › Cache server** (test, then save; RustPress restarts on it without dropping requests) or in `rp-config.toml`:

```
cache_url = "redis://:password@10.0.0.5:6379/0"   # or valkey://, rediss:// (TLS), memcached://10.0.0.6:11211
```

*   Cached pages are shared by every server, and a change on one invalidates them on all within a second.
*   Plugins get a persistent object cache: `wp_cache_*`, transients and `wp.cache`.
*   Keys are prefixed per site, so several sites can share one cache server.
*   If the cache server goes down, pages render without it (logged once, retried every 30 seconds).
*   Memcached has no passwords here: keep it on a private network, or use Redis or Valkey with `requirepass`.

```
rp cache status
rp cache flush
```

## Compiled templates, compression and minification

*   Theme templates are compiled once and reused.
*   Responses are compressed with gzip or brotli.
*   HTML and theme CSS are minified safely; `rp option set rp_minify 0` turns that off. JavaScript is left as it is.
*   Theme and plugin files get content-hashed names and are cached by browsers for a year.
*   Posts, users and terms are cached for the length of a request.

## Measuring

Logged in as an administrator, each page carries a `Server-Timing` header (database queries, database time, total) that browsers show under DevTools › Network › Timing. `RP_LOG_QUERIES=1` prints every query.

## Plugins that stay out of the way

A plugin is only called for the hooks, shortcodes and routes it registered, and only where its scope says it is needed. Owners can change this under **Plugins › Where it runs**. PHP plugins run in a long-lived PHP process with OPcache, so compiled code stays in memory and edited files are picked up within 2 seconds; turn the JIT or other php.ini values on with `php_options`. Python plugins that use the SDK’s `run()` are kept running too. Details are in [Plugins](/plugins/).

## Work moved off the request

*   Email goes out from a background queue, with retries.
*   Scheduled events and plugins’ background jobs run in workers inside the server, with retries and a breaker for failing services. See [Background jobs](/background-jobs/).

## Images and SEO

Uploaded images get sizes (thumbnail, medium, large and so on) and are served with `srcset`, so browsers download the size they need; `rp media regenerate` rebuilds them. Descriptions, link previews, JSON-LD, the sitemap, robots.txt, `/llms.txt` and Markdown versions of pages are built in, with no SEO plugin to slow pages down (**Settings › SEO**).

For headless sites, signed webhooks let your front end rebuild only what changed. See [Headless and REST API](/headless-and-rest-api/).

---

# Safety and limits

URL: https://rustpress.witsberry.com/safety-and-limits/

> How RustPress protects your site: plugin permissions and sandboxing, automatic rollback, safe mode, signed updates, and what it does not do yet.

This page lists how RustPress protects your site, how it contains plugin problems, and what this version does not do.

## Security

RustPress is built with the OWASP Top 10 in mind and reviewed against it. Release 0.1.4 went through two security reviews, and every finding is fixed (plugin SQL, CSRF, OAuth, hooks between plugins, the job queue, file serving and more).

*   Parameterized SQL everywhere, including SQL from ported plugins
*   An HTML5 allow-list sanitizer for anything untrusted users post
*   Safe URL handling
*   Nonces and capability checks on every state change, and CSRF protection for plugin forms, AJAX and REST routes
*   Brute-force limits on logins and API passwords
*   Security headers, including no framing of the admin and `nosniff`
*   Signed self-updates
*   A one-time setup key
*   SSRF protection for imports and plugins’ calls to other websites
*   Uploads served with a script-blocking policy
*   Request size and parsing limits
*   Constant-time secret comparisons
*   A private `rp-config.toml`

## Plugin permissions

A plugin declares what it needs with a `Permissions: content:read, options` header or a `"permissions"` list in `plugin.json`:

| Permission      | Allows                                                     |
| --------------- | ---------------------------------------------------------- |
| `content:read`  | Reading drafts, private content and non-public types       |
| `content:write` | Creating and changing content                              |
| `options`       | Settings other than the plugin’s own                       |
| `users`         | Users, roles and capabilities                              |
| `site`          | Site-wide changes                                          |
| `network`       | Calling other websites, optionally limited to listed hosts |

*   Without any of these, a plugin can only use its own options, public settings and its own REST routes.
*   Plugins that declare nothing keep full access and are labelled so.
*   AI and mail settings are off limits to every plugin.
*   Plugins can’t add routes in core namespaces, take core addresses, or rewrite other routes’ API responses.
*   Plugins never see visitors’ login cookies or other plugins’ cookies.
*   Calls to other websites reach public addresses only, never this server or private and cloud-metadata addresses, even after redirects.
*   `js` and `wasm` plugins are fully sandboxed. Process and HTTP plugins still run as programs on the server.

## Plugins that depend on each other

*   A plugin isn’t activated until the plugins it requires are active, at the version it needs.
*   A required plugin can’t be turned off or deleted while something active needs it.
*   A plugin may fire only its own hooks, those of plugins it requires, and shared WordPress-style hooks. It can never fire the core’s lifecycle hooks.
*   A plugin with 16 such calls already running (plugins calling each other in a loop) is stopped.

How to write plugins is covered in [Plugins](/plugins/) and the [Plugin API reference](/plugin-api/).

## Crash isolation and memory caps

Plugins run outside the core. A crash, exception or hang fails only that plugin’s part of the page, and it is logged. Plugins have time limits, and memory is capped:

| Runtime                  | Memory cap     |
| ------------------------ | -------------- |
| PHP                      | 128 MB         |
| Node                     | 256 MB         |
| Sandboxed (`js`, `wasm`) | 64 MB per call |

Plugin services that keep growing past `plugin_memory_mb` are restarted and flagged as likely leaks. Background jobs that keep failing rest instead of hammering a service that is down.

## Auto-rollback

After a change goes live, RustPress checks the site. If a page fails, or the site answers with server errors three times within 15 minutes, the change is rolled back by itself.

## Safe mode

*   **For you only:** open `/rp-admin/safe-mode?on=1`. Plugins are turned off and the default theme is used, only for your session.
*   **For everyone:** start the server with `rp serve --safe-mode`, or set `safe_mode = true`.

## Logs

**Tools › Logs** shows errors from plugins, PHP, themes, the database, email, scheduled events, crashes and visitors’ browsers. There is one file per day, split at `log_max_lines`. Logs are never served on the web, and secrets are masked. More in [Running a site](/running-a-site/).

## Signed updates

Releases are signed with Ed25519. `rp update` only installs releases with a valid signature, test-runs the new program first, and keeps the previous one. See [Install and update](/install-and-update/).

## AI agents and AI tools

Agents write only in their workspace, and every live change they propose is approved by a person after seeing the diff. Tools from other services ask before each call until you let them run, reach only https servers on the public internet, and keep their keys encrypted. The full list of guard rails is in [AI agents](/ai-agents/) and [MCP and AI tools](/mcp-and-ai-tools/).

## Not in this version

### Planned next

*   **Translations:** the admin and themes in other languages.
*   **The full block editor:** the current editor edits flat blocks and opens nested layouts in the code editor.

### Not planned for now

*   Multisite
*   XML-RPC
*   Pingbacks and trackbacks
*   Running unmodified PHP plugins that rely on WordPress internals beyond the SDK’s functions, such as WooCommerce or Elementor

If you are coming from WordPress, [Moving from WordPress](/moving-from-wordpress/) explains what carries over.

---

# What’s new

URL: https://rustpress.witsberry.com/whats-new/

> RustPress 0.1.4: plugins that do what WordPress plugins do, dependencies, background jobs, private files, MCP tools from other services and built-in SEO.

This page lists what changed in each RustPress release, newest first, and where each feature is documented. The latest version is **0.1.5**.

## 0.1.5: the page cache stays full on Tailwind themes

On a site with a Tailwind CSS theme, the page cache could be emptied every minute or two with the reason “theme CSS rebuilt”, even though nothing had changed, and each time Cloudflare’s cache was purged too. Visitors then got fresh, slower pages instead of cached ones.

*   The theme’s CSS is now rebuilt only when its templates or CSS actually change.
*   The page cache (and Cloudflare) is emptied only when the built CSS is different.
*   The server log says which file triggered each rebuild.

If your theme uses Tailwind (the built-in theme builder and AI-built themes do), update to keep pages fast. More on caching in [Performance](/performance/).

## 0.1.4: plugins that do what WordPress plugins do

The biggest release so far. Plugins can do what WordPress plugins do, they can build on each other, slow work moves to background jobs, and AI agents can use tools from other services.

### Plugins can do what WordPress plugins do

Every one of these works in all four SDKs (JavaScript, PHP, Python and Rust):

*   Custom fields and meta boxes, drawn and checked by RustPress, for posts, users and terms
*   Roles and capabilities, including capability types for custom content types
*   Rewrite rules and query variables
*   Admin menus, settings pages drawn by the core, and full-screen admin pages
*   Editor blocks with a settings form, a live preview, or their own editing UI
*   Templates for a plugin’s own content types
*   Scripts and styles, with dependencies and content-hashed file names
*   Nonces and CSRF protection for forms, AJAX and REST routes
*   `WP_Query` with meta and taxonomy queries
*   `$wpdb` and `dbDelta` for ported plugins, limited to safe statements
*   Calls to other websites, limited to the hosts a plugin declares
*   Dashboard and sidebar widgets

Details and code: [Plugin API reference](/plugin-api/).

### Plugins build on each other

A plugin or theme declares what it needs, and RustPress won’t turn it on until that is there:

```
Requires Plugins: shop-core (>=1.2)
Requires RustPress: 0.1.4
```

A required plugin can’t be deactivated or deleted while something active needs it. Plugins extend each other through hooks, as in WordPress, with rules on who may fire what.

### Background jobs

Work that is slow or may fail, such as calling a payment service or sending in bulk, runs in background workers with retries, growing pauses and a breaker that rests a failing job. Several servers can share one database without running a job twice. WooCommerce’s Action Scheduler functions work, and **Tools › Scheduled tasks** shows failed jobs to retry or delete. See [Background jobs](/background-jobs/).

### Private files for plugins

Invoices, paid downloads and exports live in a plugin’s own folder, which is never served directly. The plugin hands a file to a visitor only after its own checks. Images or PDFs a plugin makes are sent as they are.

### The admin

*   The media library dialog wherever an image or file is chosen: upload with progress, search, filter and alt text editing.
*   Dashboard widgets can be hidden and arranged by each user.
*   **Clear cache** is in the admin toolbar and under **Settings › Speed**.

### AI agents

*   Agents can use tools from other services through MCP (HeyGen, design and automation tools, your own systems). Each call is approved by you unless you let it run at once. Set them up under **AI › External tools**.
*   AI apps connect to your site with scoped keys or OAuth under **AI › Connections**.
*   Agents can read the web when you allow it, use files you attach, draw icons and images, and gather requirements before building.
*   The SDK references, the plugin protocol and the skills agents load (plugin-builder, secure-plugins) cover everything in this release.

See [AI agents](/ai-agents/) and [MCP and AI tools](/mcp-and-ai-tools/).

### Built-in SEO

RustPress prints descriptions, link previews, JSON-LD and robots.txt itself, serves `/llms.txt` and Markdown versions of pages, and makes a site icon in every size from one image. Set it up under **Settings › SEO**. Themes no longer need their own meta tags.

### Security

This release went through two security reviews, and every finding is fixed: plugin SQL, CSRF, OAuth, hooks between plugins, the job queue, file serving and more.

## Updating

From 0.1.1 on, use **Dashboard › Updates** or run `rp update`. The release is verified against its signature, and running sites switch to the new version without dropping a request. Earlier versions: replace the `rp` program and restart once. Full steps are in [Install and update](/install-and-update/).

The release notes and downloads for every platform are on the [GitHub releases page](https://github.com/Witsberry/RustPress/releases).

---

# Plugin API

URL: https://rustpress.witsberry.com/plugin-api/

> Reference for RustPress plugins: meta boxes, roles, rewrite rules, blocks, WP_Query, $wpdb, HTTP calls, private files, hooks and plugin dependencies.

This page is the reference for what a plugin can do. Start with [Plugins](/plugins/) for runtimes and a first plugin. Everything here works in all four SDKs (JavaScript, PHP, Python and Rust), sent over the same JSON protocol. Each plugin is described once (`describe`), then called only for what it registered. In JavaScript, `const rp = require('rustpress')()` gives the SDK object; the examples call it `rp` or `wp`, which are the same thing.

## The manifest

```
{
  "name": "My Plugin",
  "version": "1.0.0",
  "runtime": "js",
  "entry": "plugin.js",
  "permissions": ["content:read"],
  "network": ["api.stripe.com"],
  "requires": ["shop-core (>=1.2)"],
  "requires_rustpress": "0.1.4",
  "scope": { "areas": ["front"], "paths": ["/shop/*"], "post_types": ["product"] }
}
```

*   `runtime`: `js`, `wasm`, `stdio` or `http`. A folder with a classic PHP file (a `Plugin Name:` header) needs no manifest.
*   `stdio` runs `entry` by extension (`.php`, `.js`, `.py`, `.rb`) or a `"command"`. `http` takes a `"url"` or a `"serve"` command the core starts with `{port}` / `$PORT`.
*   `scope` limits where filters and actions run: `areas` (front, admin, rest), `paths`, `exclude_paths`, `post_types`, `pages` (front\_page, home, single, page, archive, search, 404). In PHP: `Load On: front, admin` and `Load On Paths: /shop/*`. Shortcodes, blocks, routes, admin pages and scheduled events aren’t limited.
*   Sandboxed JavaScript can only require the SDK. It has no `fetch`, timers, files or `process`. Each call starts fresh with a time budget and 64 MB of memory, so keep data in options or tables.

## Dependencies between plugins

Declare hard needs in `plugin.json`, or in a PHP header and a theme’s `style.css`:

```
Requires Plugins: shop-core, payments (>=1.2)
Requires RustPress: 0.1.4
```

*   A package isn’t activated until every plugin it requires is installed, active and at least that version, and the site runs that RustPress.
*   A required plugin can’t be deactivated or deleted while something active needs it. The Plugins screen says which.
*   Versions are written `(>=1.2)`, `>=1.2`, `(>=v2)` or `(>=1.2-beta)`. Ranges and other operators aren’t supported, and a requirement RustPress can’t read keeps the package off.
*   Anything optional is an integration you check for with `isPluginActive(slug)` / `is_plugin_active()`. Packages talk through hooks and REST routes, never by reading each other’s tables, options or files.

## Hooks between plugins

A plugin’s public extension points are hooks it fires, named with its slug. Firing one runs its own callbacks, then every other package’s:

| SDK        | Fire an action                                       | Filter a value                                                | Is a plugin there?                    |
| ---------- | ---------------------------------------------------- | ------------------------------------------------------------- | ------------------------------------- |
| PHP        | `do_action( 'shop_core_order_paid', $id )`           | `apply_filters( 'shop_core_cart_total', $t, $cart )`          | `is_plugin_active( 'shop-core' )`     |
| JavaScript | `await rp.doAction('shop_core_order_paid', id)`      | `await rp.applyFilters('shop_core_cart_total', t, cart)`      | `rp.isPluginActive('shop-core')`      |
| Python     | `do_action("shop_core_order_paid", id)`              | `apply_filters("shop_core_cart_total", t, cart)`              | `is_plugin_active("shop-core")`       |
| Rust       | `do_action("shop_core_order_paid", vec![json!(id)])` | `apply_filters("shop_core_cart_total", json!(t), vec![cart])` | `is_plugin_active(&req, "shop-core")` |

*   A plugin may fire its own hooks, those of plugins it lists in `requires`, and shared WordPress-style hooks no plugin owns (such as `the_content`).
*   It may never fire core lifecycle actions (`init`, `wp_head`, `save_post`…), hooks starting with `rp_`, or scheduled events’ hooks.
*   Listeners run as the visitor, never as an administrator, and see who fired the hook in `context.fired_by`.
*   Document every hook you fire in your `AGENTS.md`: it is your plugin’s API.

## Custom fields and meta boxes

Describe `meta_boxes` and RustPress draws the fields on the post editor, checks every value and saves it as post meta. A wrong value stops the save and tells the editor what to fix.

```
rp.addMetaBox('product_details', {
  title: 'Product details', postTypes: ['product'], context: 'side',
  fields: [
    { key: 'price', label: 'Price', type: 'number', min: 0, step: 0.01, required: true },
    { key: 'colour', label: 'Colour', type: 'select', options: ['red', 'blue'] },
    { key: 'gallery', label: 'Gallery', type: 'repeater', fields: [{ key: 'image', type: 'image' }] }
  ]
});
```

*   Field types: `text`, `textarea`, `html`, `number`, `url`, `email`, `date`, `time`, `datetime`, `color`, `checkbox`, `select`, `radio`, `image`, `file`, `post`, `user`, `repeater`.
*   Drawn boxes (pass a `render(post)` callback) return their own HTML (form controls allowed, no scripts) and save in `save_post`.
*   Boxes can also target user profiles (`object: 'user'`) or terms (`object: 'term'` with `taxonomies`).
*   Read and write with `rp.getPostMeta / updatePostMeta / deletePostMeta`, or `get_post_meta`, `update_post_meta`, `register_post_meta` and `add_meta_box` in PHP. Keys named after the plugin need no permission.

## Roles and capabilities

With the `users` permission a plugin can `add_role`, `remove_role` (only roles it added), `add_cap`, `remove_cap`, `set_user_role` (never to or from administrator) and check `user_can`. Granting site-wide capabilities such as `manage_options` also needs `site`. A post type with `"capability_type": "book"` gets `edit_books`, `publish_books` and the rest.

## Rewrite rules and query variables

```
"rewrite_rules": [{ "regex": "^events/([0-9]{4})/?$",
  "query": "index.php?post_type=event&event_year=$matches[1]", "after": "top" }],
"query_vars": ["event_year"]
```

Top rules run before the core’s addresses, bottom ones only when nothing else matched. Core addresses can’t be rewritten. The plugin’s variables arrive in `context.query.vars`; pick a template with the `template_include` filter.

## Templates for your content types

A plugin that registers a content type or taxonomy can ship `templates/single-<type>.html`, `archive-<type>.html` or `taxonomy-<taxonomy>.html`. They are used when the active theme has no file of that name, and wrap the theme’s layout:

```
{% extends layout %}
{% block main %}<article><h1>{{ post.title }}</h1>{{ post.content|safe }}</article>{% endblock %}
```

## Editor blocks

Describe `block_types` with WordPress-style `attributes`. The editor offers the block under “From plugins”, shows the attributes as a settings form with a live preview, and saves only values that differ from the default. Every view renders it with a `block` call; attributes arrive typed, with values that don’t fit replaced by the default. For your own editing UI, register an editor script and call `rpBlocks.registerEdit(name, (el, ctx) => { … })`.

## Scripts and styles

Describe `assets` (handle, src, type, deps, strategy, where: front, admin, login or editor), or enqueue them in `wp_enqueue_scripts` as in WordPress. Each handle is printed once, dependencies first. Files in the plugin get content-hashed names cached for a year, so `version` doesn’t need bumping.

## Admin pages, settings and widgets

*   Admin pages can be a menu of their own (`top_level`, `position`), sit under a core menu (`parent`), or be full screen for page builders.
*   An admin page with `sections` of fields is drawn, checked and saved by the core, with no HTML to write. `rp_settings_saved` fires after a save.
*   Dashboard widgets (`dashboard_widgets`) can be hidden and moved by each user. Sidebar widgets are blocks.
*   Every admin screen has the media dialog: `await rpMedia.open({ type: 'image' })`, or WordPress’s `wp.media()`.

## Querying content

`query_posts` takes `WP_Query` arguments, including `meta_query` (nested AND/OR, all compare operators and types), `tax_query`, ordering by meta value and paging up to 1000 per page. Published content of public types needs no permission.

Ported code can use `$wpdb` and `dbDelta` in PHP. The core parses each statement and allows `CREATE TABLE` for the plugin’s own tables, reads and writes on its own tables, and reads on posts, terms and comments with `content:read`. Users, options, passwords and commenters’ emails and IPs are never reachable. Every value is bound as a parameter.

## Plugin tables

```
await rp.db.createTable('orders', { status: 'string', total: 'float', data: 'json' }, ['status']);
const { id } = await rp.db.insert('orders', { status: 'paid', total: 12.5 });
const { rows } = await rp.db.select('orders', { status: 'paid', total: { '>=': 10 } },
  { orderBy: 'id', order: 'desc', limit: 20 });
```

Types are `int`, `float`, `bool`, `string`, `text`, `datetime` and `json`; `id` is added as the key. Conditions use `=`, `!=`, `<`, `<=`, `>`, `>=`, `like` and `in`. Up to 32 tables and 64 columns, 1000 rows per select. In PHP: `rp_db_create_table`, `rp_db_insert`, `rp_db_select` and friends. When a plugin is removed, the owner can delete its tables with it.

## Calling other websites

The `http` host call needs the `network` permission; `"network": ["api.stripe.com", "*.paypal.com"]` (PHP header `Network:`) limits it to those hosts. Only public addresses are reached, never this server or private and cloud-metadata addresses, even after redirects. Calls take at most 15 seconds and 5 MB. SDKs: `rp.http(method, url, { headers, body })`, `wp_remote_get/post/request` and `rp_http()` in PHP, `http()` in Python.

## Private files

Invoices, downloads and exports go in `rp-content/plugin-files/<slug>/`, which is never served directly: `rp.files.put/get/delete/exists/list`, `rp_file_put()` and friends. To hand one to a visitor after your own checks, a page or route answers:

```
{ "file": "invoices/42.pdf", "download_name": "Invoice 42.pdf" }
```

Files can be up to 50 MB each and 2 GB per plugin. Bytes a plugin makes, such as a QR code or a chart, go back as `body_base64` with a `Content-Type`.

## Requests, cookies, nonces and CSRF

*   `context.request` carries the method, path, query, IP, user agent and only the plugin’s own cookies (`rp_<slug>__<name>`). The login cookie and other plugins’ cookies are never shown.
*   `set_cookie` and `redirect` host calls change the response. Pages for visitors with `rp_` cookies are never shared by the page cache.
*   `nonce_create` / `nonce_verify` are made for the user and session, and namespaced to the plugin.
*   Changing requests that carry cookies must come from this site or carry a CSRF token from `GET /rp-csrf`, otherwise they get 419. Webhooks and application passwords (no cookies) pass.

## AI tools

Plugins can give the site’s agents and MCP clients their own tools with `rp.registerAiTool()` or `rp_register_ai_tool()`. See [MCP and AI tools](/mcp-and-ai-tools/).

## SEO, cache and media storage hooks

*   **SEO:** `rp_schema_graph` adds JSON-LD nodes (Product, Event, FAQPage…), `rp_seo_output` turns the core’s tags off for an SEO plugin, `rp_llms_txt`, `rp_ai_readable` and `rp_llms_posts` shape what AI tools can read.
*   **Page cache:** `rp_page_cacheable`, `rp_page_cache_key`, `rp_page_cache_ttl`, and the `rp_cache_purged` action for purging a CDN.
*   **Media storage (S3, R2, a CDN):** copy files in `add_attachment`, remove them in `delete_attachment`, then set the `rp_media_url_base` option. Storage plugins run as PHP, Node or Python, not in the sandbox.

## Hooks you can use

Filters and actions keep WordPress’s names and arguments where they exist: request hooks (`init`, `template_redirect`, `template_include`, `wp_headers`), queries and links (`pre_get_posts`, `post_link`), output (`wp_head`, `the_content`, `body_class`, `render_block`), posts and data (`save_post`, `transition_post_status`), comments (`preprocess_comment`), users and login (`authenticate` for a second factor, `wp_login`), media (`wp_handle_upload_prefilter`), settings (`update_option_{name}`), REST (`rest_prepare_{type}`) and admin (`admin_notices`, `admin_bar_menu`). Plugins can’t rewrite other routes’ API responses, so one plugin can never change what the admin sees, approvals included.

The complete list of operations, fields and limits is in [PROTOCOL.md](https://github.com/Witsberry/RustPress/blob/main/bundled/sdk/PROTOCOL.md) on GitHub, which is also written to `sdk/PROTOCOL.md` beside every site’s `rp-config.toml`.

---

# Background jobs

URL: https://rustpress.witsberry.com/background-jobs/

> Scheduled posts, email, WP-Cron events and plugin jobs run inside RustPress with retries, backoff and a breaker. Action Scheduler functions work too.

This page explains how RustPress runs work in the background: scheduled posts, email, WordPress-style cron events and plugins’ background jobs. On a VPS, in Docker, or on Render, Railway or Fly.io, all of it runs inside `rp serve` and you don’t need a cron job.

## What runs by itself

*   **Scheduled events** (`wp_schedule_event` and friends) are checked every 30 seconds.
*   **Background jobs** run as soon as they are due, on `queue_workers` workers (default 2).
*   **Scheduled posts** are published on time, and **email** is sent from a queue with retries.
*   **Upkeep**: daily cleanup, weekly database compaction and the twice-daily update check.

## Queueing a job from a plugin

Use a job for work that shouldn’t slow a page or may fail: syncing an order, sending to an API, rebuilding an index. A worker calls the plugin’s action with the arguments.

```
// JavaScript
rp.addAction('myshop_sync_order', async (orderId) => {
  const r = await rp.http('POST', 'https://api.example.com/orders', { body: { id: orderId } });
  if (r.status >= 500) throw new Error('service down');   // retried later
});
await rp.queue.push('myshop_sync_order', [orderId],
  { attempts: 5, backoff: [10, 60, 300], unique: 'order-' + orderId });
```

```
// PHP
add_action( 'myshop_sync_order', 'myshop_sync_order' );
wp_rs_queue_push( 'myshop_sync_order', array( $order_id ), array( 'attempts' => 5 ) );

// Action Scheduler's functions work too
as_enqueue_async_action( 'myshop_sync_order', array( $order_id ) );
as_schedule_single_action( time() + 3600, 'myshop_sync_order', array( $order_id ) );
```

Python and Rust plugins use `queue_push()` and `queue_cancel()`. Cancel a waiting job by its id or its `unique` key.

## Options

| Option     | What it does                                                                                        |
| ---------- | --------------------------------------------------------------------------------------------------- |
| `delay`    | Seconds to wait before the first run                                                                |
| `attempts` | How many times to try (default 3)                                                                   |
| `backoff`  | Pauses between tries in seconds, e.g. `[30, 120, 600]`; the last one repeats, plus up to 20% jitter |
| `timeout`  | Seconds one run may take                                                                            |
| `unique`   | Keeps one waiting job per key: pushing again returns the same id                                    |
| `queue`    | A named queue, to group jobs                                                                        |

## Failures and retries

*   A job fails when its action throws, or replies with an error. It runs again after the next backoff step until its attempts are used up.
*   Then it is kept as failed under **Tools › Scheduled tasks**, where you can retry or delete it, and the `rp_job_failed` action fires with the id, plugin, hook, arguments, attempts and error.
*   A hook that fails 5 times in a row rests, from a minute up to an hour, instead of hammering a service that is down.
*   A one-off cron event whose plugin callback fails is retried the same way.
*   Limits: arguments up to 64 KB (pass ids, not data), at most 10,000 waiting jobs per plugin, at most 50 jobs per pass per worker.

## Several servers on one database

Run them all. A database lease lets one server run the scheduled events at a time, and each job is claimed by exactly one worker. To turn the built-in runner off on a server, set `background_cron = false` in `rp-config.toml`; then a cron job must run `rp cron run`.

## Shared hosting and serverless

Without `rp serve` (CGI or FastCGI on shared hosting, or serverless), add a system cron job that runs every minute, either the command or the address:

```
* * * * * cd /path/to/site && /path/to/rp cron run >/dev/null 2>&1
* * * * * curl -fsS https://example.com/rp-cron >/dev/null
```

Without either, RustPress does the same work after visits, at most once a minute, so a quiet site may run late. `/rp-cron` answers at most once every 10 seconds. See [Hosting](/hosting/) for the shared hosting steps.

## Seeing what’s queued

```
rp cron list   # scheduled events and job counts
rp cron run    # run what is due once
```

**Tools › Scheduled tasks** shows events and jobs, with failures. Every operation and limit is in the [Plugin API reference](/plugin-api/).

---

# Hosting

URL: https://rustpress.witsberry.com/hosting/

> Put a RustPress site online: Linux with systemd and HTTPS, Docker, Render, Railway, Fly.io, shared hosting with FastCGI, Windows and macOS.

RustPress is one program, `rp` (`rp.exe` on Windows). It contains the web server, the admin, the default theme and the plugin SDKs, and SQLite is built in, so you don’t need Rust, PHP, a web server or a database server to run a site. This page shows where it runs and how to set each option up.

## Where can I host it?

| Where                                                                                | Works?                                                                                | How                               |
| ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------- | --------------------------------- |
| Your own server or a VPS (Hostinger VPS, DigitalOcean, Hetzner, AWS EC2, Lightsail…) | **Yes, everything**                                                                   | [A Linux server](#server)         |
| Docker anywhere                                                                      | **Yes, everything**                                                                   | [Docker](#docker)                 |
| Render, Railway, Fly.io (with a disk or volume)                                      | **Yes, everything**                                                                   | [Container platforms](#platforms) |
| DigitalOcean App Platform, or any platform without a disk                            | Yes, with limits: outside database and media storage, themes and plugins in the image | [Container platforms](#platforms) |
| Shared hosting (Hostinger, cPanel, Plesk, DirectAdmin…)                              | Yes, with limits: FastCGI is fast, plain CGI has fewer features                       | [Shared hosting](#shared)         |
| AWS Lambda, Google Cloud Run                                                         | Partly: untested, no background work between requests                                 | [Serverless](#serverless)         |
| Cloudflare Workers, Vercel or Netlify functions                                      | No, not for the site itself                                                           | [Cloudflare](#cloudflare)         |

To download `rp` and run the setup wizard first, see [Install and update](/install-and-update/).

## A Linux server with systemd

A small VPS is enough: 1 CPU and 512 MB of memory run a typical site comfortably. These steps are for Ubuntu, Debian, Fedora, Rocky and similar. RustPress listens on the server itself, and a reverse proxy in front of it serves the public domain over HTTPS.

### Install the program and a site folder

```
sudo useradd --system --home /srv/mysite --create-home rustpress
sudo install -d -o rustpress -g rustpress /opt/rustpress
sudo install -m 755 -o rustpress -g rustpress rp /opt/rustpress/rp
sudo ln -s /opt/rustpress/rp /usr/local/bin/rp
```

The program lives in a folder owned by the `rustpress` user, so **Dashboard › Updates** can update it from the admin. If you keep it root-owned instead, updates still work, but only from the shell with `sudo rp update`.

### Run it as a service

Create `/etc/systemd/system/rustpress.service`:

```
[Unit]
Description=RustPress
After=network-online.target
Wants=network-online.target

[Service]
User=rustpress
WorkingDirectory=/srv/mysite
ExecStart=/opt/rustpress/rp serve --root /srv/mysite --listen 127.0.0.1:8080
# `systemctl reload rustpress` restarts without dropping a request
ExecReload=/bin/kill -USR2 $MAINPID
Restart=on-failure
# Optional: Environment=RP_DATABASE_URL=mysql://user:password@127.0.0.1:3306/rustpress

[Install]
WantedBy=multi-user.target
```

```
sudo systemctl daemon-reload
sudo systemctl enable --now rustpress
sudo systemctl status rustpress        # should say "active (running)"
journalctl -u rustpress -f             # the log
sudo systemctl reload rustpress        # restart without downtime
```

Scheduled posts, email, cron events and plugins’ background jobs run inside the server, so no cron job is needed. See [Background jobs](/background-jobs/).

### HTTPS with Caddy (easiest)

Caddy gets and renews certificates by itself. Point your domain’s DNS at the server, put this in `/etc/caddy/Caddyfile`, then run `sudo systemctl reload caddy`:

```
example.com {
    reverse_proxy 127.0.0.1:8080
}
```

### HTTPS with nginx

```
server {
    listen 80;
    server_name example.com;
    client_max_body_size 256m;               # largest upload

    location / {
        proxy_pass http://127.0.0.1:8080;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_read_timeout 300s;             # AI agents and big imports take a while
    }
}
```

Add a certificate with `sudo certbot --nginx -d example.com`, then run the setup wizard at `https://example.com/rp-admin/install`. RustPress takes visitors’ real addresses from `X-Forwarded-For` only when the proxy runs on the same machine (see `trusted_proxies` in [Configuration](/configuration/)).

### Firewall

```
sudo ufw allow OpenSSH && sudo ufw allow 80,443/tcp && sudo ufw enable
```

Keep `--listen 127.0.0.1:…` so RustPress itself isn’t exposed directly; only the proxy needs to be reachable.

## Docker

The repository has a `Dockerfile` that builds RustPress from source into a small image running `rp serve`. Everything the site keeps (settings, the SQLite database, uploads, themes, plugins, logs) is in `/data`, so give that folder a persistent volume:

```
docker build -t rustpress .
docker run -d --name mysite -p 127.0.0.1:8080:8080 -v mysite:/data \
  -e RP_SECRET_KEY=$(openssl rand -hex 32) --restart unless-stopped rustpress
```

Put Caddy or nginx in front for HTTPS as above. `docker exec mysite rp update` switches the running container over without downtime, but a recreated container starts from its image again, so rebuild the image to keep an update. The site in the volume is kept.

## Container platforms

Render, Railway, Fly.io and DigitalOcean build the `Dockerfile` from your copy of the repository and give you HTTPS. RustPress reads its settings from the environment there:

| Variable             | What it does                                                                                          |
| -------------------- | ----------------------------------------------------------------------------------------------------- |
| `PORT`               | Set by the platform; RustPress listens on `0.0.0.0:$PORT`                                             |
| `RP_SECRET_KEY`      | **Set it** (64 random characters, e.g. `openssl rand -hex 32`): keeps people logged in across deploys |
| `RP_DATABASE_URL`    | An outside database; without it, SQLite in `/data`                                                    |
| `RP_TRUSTED_PROXIES` | `private` (already set in the image): real visitor addresses come from the platform’s load balancer   |
| `RP_CACHE_URL`       | Optional Redis or Valkey (Render Key Value, Railway Redis, Upstash…)                                  |

| Platform                  | Config                         | Disk             | Steps                                                                                                                                            |
| ------------------------- | ------------------------------ | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| Render                    | `deploy/render/render.yaml`    | Yes (paid plans) | New › Blueprint › your repository. The blueprint adds a 5 GB disk at `/data` and generates `RP_SECRET_KEY`.                                      |
| Railway                   | `deploy/railway/railway.json`  | Yes (volumes)    | New project › Deploy from GitHub; add a Volume at `/data`; add `RP_SECRET_KEY`.                                                                  |
| Fly.io                    | `deploy/fly/fly.toml`          | Yes (volumes)    | `fly volumes create rustpress_data --size 3`, `fly secrets set RP_SECRET_KEY=$(openssl rand -hex 32)`, `fly deploy --config deploy/fly/fly.toml` |
| DigitalOcean App Platform | `deploy/digitalocean/app.yaml` | No               | Needs an outside database and media storage (below).                                                                                             |

*   **First visit:** the setup wizard asks for a one-time setup key, printed in the platform’s logs at start, so nobody else can claim a new site.
*   Run **one instance** with a disk. For several instances, use an outside database, Redis or Valkey (`RP_CACHE_URL`) and S3 or R2 media storage, and install themes and plugins in the image.
*   **Outside databases** (Neon, Supabase, Render, Railway, DigitalOcean PostgreSQL; PlanetScale or Aiven MySQL): paste their URL into `RP_DATABASE_URL`. `?sslmode=require` encrypts, `?sslmode=verify-full` also checks the certificate. MySQL also accepts `?ssl-mode=REQUIRED`.
*   **Platforms without a disk** throw the container’s files away on every deploy: the database must be outside, uploads must go to S3, R2 or Spaces with a media storage plugin, themes and plugins must be in the image, and logs and AI chats start empty after a restart.

## Serverless (AWS Lambda, Cloud Run)

Not tested. A container platform that keeps RustPress running (App Runner, ECS/Fargate, Cloud Run with minimum instances 1, plus an outside database and storage) works like the platforms above. Functions that start per request can serve pages, but background work (scheduled tasks, AI agents, email retries) only runs during a request: schedule `/rp-cron` with EventBridge and keep AI work on another host.

## Cloudflare

Cloudflare Workers can’t run RustPress itself: they are small functions with no files and no background work, and RustPress is a full server. What works well:

*   **Cloudflare in front of RustPress:** DNS, HTTPS, edge caching and attack protection. **Settings › Speed** sets it up: how long Cloudflare may keep pages, a zone ID and API token so every change purges Cloudflare’s cache, and the Cache Rule to paste into Cloudflare. Without that rule every page passes through to your server. Set `trusted_proxies` to Cloudflare’s ranges (or `private` behind a tunnel).
*   **Cloudflare R2** for media, with an S3-compatible media storage plugin.
*   **Headless:** the public site on Cloudflare Pages or Workers, RustPress for the admin and API. See [Headless and REST API](/headless-and-rest-api/).

## Shared hosting (FastCGI and CGI)

Shared hosting runs your files through a web server you can’t configure (usually Apache or LiteSpeed) and doesn’t let your own programs keep running. RustPress runs there as `rp cgi`, started by the web server:

*   **FastCGI** (Apache mod\_fcgid, LiteSpeed, nginx, Caddy): the web server keeps RustPress running and one process answers many requests. As fast as `rp serve`: measured at about 80,000 cached pages a second behind nginx, and about 1 ms per page through Apache. Most shared hosts have it.
*   **CGI** (any host with cgi-bin): a new RustPress for every request. Still quick: about 6 ms for a cached page and 12 ms for a new one; each PHP plugin call adds about 25 ms.

`rp cgi` picks the right one by itself, and `rp cgi-setup` writes what’s needed.

### Steps

1.  **Check you have SSH** (hPanel › Advanced › SSH Access on Hostinger; “Terminal” in cPanel).
2.  **Upload `rp`** (the Linux x86\_64 build; ARM servers: aarch64) to your home folder, not into `public_html`: `mkdir -p ~/rustpress && mv rp-linux-x86_64 ~/rustpress/rp && chmod +x ~/rustpress/rp`
3.  **Make the site folder next to `public_html`**, never inside it, and write the web files: `~/rustpress/rp cgi-setup --public ~/public_html --root ~/rustpress/site`. This writes two tiny start scripts, an `.htaccess` that sends every address to RustPress, and links the uploads folder so images are served from disk. An existing `.htaccess` is kept and the new one saved as `.htaccess.rustpress` (`--force` replaces it).
4.  **Open your domain**: the setup wizard starts. Pick SQLite or your host’s MySQL database (create it in the panel first).
5.  **Add a cron job** every minute (every 5 if your host allows no less) with the command `rp cgi-setup` printed, such as `* * * * * /home/you/rustpress/rp cron run --root /home/you/rustpress/site >/dev/null 2>&1`. Hosts that only allow web requests: `curl -fsS https://your-domain/rp-cron`.

**Updating:** Dashboard › Updates works as usual, or `~/rustpress/rp update` over SSH. Running FastCGI processes finish their requests and the web server starts the new version.

### What works on shared hosting

|                                                                 | FastCGI                       | Plain CGI                         | Instead                           |
| --------------------------------------------------------------- | ----------------------------- | --------------------------------- | --------------------------------- |
| Pages, admin, REST API, editor, media, comments, users, imports | Yes                           | Yes                               |                                   |
| Page cache                                                      | Yes (memory and files)        | Yes (files)                       | Add Redis if your host has it     |
| JavaScript and WebAssembly plugins                              | Yes                           | Yes                               |                                   |
| PHP plugins                                                     | Yes (kept running)            | Yes, slower                       | Prefer JavaScript plugins on CGI  |
| Node, Python or other service plugins (`http`)                  | Yes, while the process lives  | No                                | A `js` version, or a VPS          |
| Scheduled tasks and email queue                                 | Yes                           | After visits or with the cron job | Add the cron job                  |
| AI agents with API providers                                    | Yes                           | Yes                               |                                   |
| AI agents through Claude Code CLI                               | Only if installed on the host | Same                              | Use an API key provider           |
| Building Rust plugins, Tailwind builds                          | Usually not / usually yes     | Same                              | Build on your computer and upload |
| Updates without downtime                                        | Yes                           | Yes                               |                                   |

Your host may limit how long a background process runs (some stop long AI chats; send a message to continue) and how many processes you may have at once (heavy traffic on plain CGI; FastCGI uses one).

### Build on your computer, publish to the host

*   **Themes and plugins:** Export a .zip on your computer and Upload it on the host, or use `rp theme export` / `rp plugin export` and `rp theme install` / `rp plugin install`.
*   **Content:** Tools › Export on your computer, Tools › Import on the host.
*   **Everything:** `rp backup` makes one zip of every theme and plugin.

On a server of your own you can also use FastCGI with nginx, Caddy or IIS: run `rp cgi --root /srv/site --fcgi-listen 127.0.0.1:9000` as a service and point the web server at it. `rp serve` behind a reverse proxy is simpler and just as fast.

## Windows and macOS servers

**Windows:** run `rp.exe serve --root C:\sites\mysite --listen 127.0.0.1:8080`. To start it with the machine, use NSSM (`nssm install RustPress C:\rustpress\rp.exe serve --root C:\sites\mysite --listen 127.0.0.1:8080`) or Task Scheduler. Use IIS with Application Request Routing, or Caddy for Windows, as the HTTPS front. Updates take effect when the service restarts, in a few seconds.

**macOS:** run it with `launchd`. Save this as `~/Library/LaunchAgents/com.rustpress.mysite.plist` and load it with `launchctl load`. Updates switch over without downtime, as on Linux.

```
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"><dict>
  <key>Label</key><string>com.rustpress.mysite</string>
  <key>ProgramArguments</key><array>
    <string>/usr/local/bin/rp</string><string>serve</string>
    <string>--root</string><string>/Users/you/sites/mysite</string>
    <string>--listen</string><string>127.0.0.1:8080</string>
  </array>
  <key>RunAtLoad</key><true/>
  <key>KeepAlive</key><true/>
</dict></plist>
```

## Several sites on one server

One `rp` program can run any number of sites, each with its own folder, port and service. With a systemd template, `/etc/systemd/system/rustpress@.service`:

```
[Unit]
Description=RustPress site %i
After=network-online.target

[Service]
User=rustpress
WorkingDirectory=/srv/%i
ExecStart=/opt/rustpress/rp serve --root /srv/%i
ExecReload=/bin/kill -USR2 $MAINPID
Restart=on-failure

[Install]
WantedBy=multi-user.target
```

Give each site its own `listen` port in its `rp-config.toml` (8080, 8081…), run `sudo systemctl enable --now rustpress@shop rustpress@blog`, and add one Caddy or nginx block per domain. One `rp update` switches every site over. Several sites can also share one MySQL or PostgreSQL database with different `table_prefix` values.

Next: [Running a site](/running-a-site/) covers email, backups, logs, security and troubleshooting.

---

# Running a site

URL: https://rustpress.witsberry.com/running-a-site/

> Day-to-day RustPress: email setup, backups and restoring, logs, automatic cleanup, a security checklist and fixes for common problems.

This page covers what you do once a site is online: email, the site address, logs, backups, cleanup, security and fixing common problems. To put a site online first, see [Hosting](/hosting/).

## Email

Password resets, comment notices and plugin mail go out in the background. Set up sending under **Settings › Email**: SMTP (your email provider, or a service such as Postmark, Mailgun, Amazon SES or Resend) or the server’s `sendmail`. *Send test email* checks it and shows any error. Failed mail is retried for a few hours.

## Site address

The address saved at setup is used for every link. To move to a new domain, or from `http://` to `https://`, change *Software Address* and *Site Address* under **Settings › General**, or from the shell:

```
rp option set siteurl https://example.com --root /srv/mysite
rp option set home https://example.com --root /srv/mysite
```

## AI agents

Open **AI › Agents**, pick a provider, paste an API key and choose a model. Keys are stored encrypted with the site’s `secret_key` and never shown again. Set a daily token limit there to cap costs. What you type, and the site content an agent reads, is sent to the provider you chose; use a local model (Ollama, LM Studio) if nothing may leave the server. More in [AI agents](/ai-agents/).

## Logs

**Tools › Logs** shows what went wrong, day by day: plugin failures and PHP errors, theme and template errors, database errors, crashes, failed emails and scheduled events, update problems, and JavaScript errors from visitors’ and admins’ browsers (only from the site’s own pages, rate-limited). Filter by level, source and text, download a day, or press *Ask an agent* to hand an error to an AI agent.

The files are in `rp-content/logs/`, one per day, split into parts of `log_max_lines` lines, never served on the web, with passwords, tokens and keys masked. Logs older than 30 days are removed by the daily cleanup. The same lines go to standard error: `journalctl -u rustpress` under systemd, `docker logs mysite` in Docker.

## Backups

**Back up the whole site folder**: `rp-config.toml` and `rp-content/`. The config holds the secret key that encrypts stored AI keys and signs logins, so keep it with the backup.

*   **SQLite:** copy the folder while the server is stopped, or take a live copy with `sqlite3 rp-content/database.sqlite ".backup backup.sqlite"`.
*   **MySQL or MariaDB:** `mysqldump rustpress > rustpress.sql`, plus the site folder for uploads, themes and plugins.
*   **PostgreSQL:** `pg_dump rustpress > rustpress.sql`, plus the site folder.
*   `rp backup` zips every theme and plugin. `rp export-content site.xml` writes a WordPress export file that RustPress or WordPress can import.

A simple nightly backup with SQLite, in the `rustpress` user’s crontab, keeping one copy per weekday:

```
0 3 * * * sqlite3 /srv/mysite/rp-content/database.sqlite ".backup /srv/backups/db-$(date +\%a).sqlite" && tar czf /srv/backups/files-$(date +\%a).tar.gz -C /srv/mysite rp-config.toml rp-content/uploads rp-content/themes rp-content/plugins
```

Copy `/srv/backups` off the server too. **Restoring:** stop the server, put the site folder back (and load the SQL dump for MySQL or PostgreSQL), and start the server.

## Automatic cleanup

Once a day RustPress clears what it no longer needs: AI temporary and build files, uploaded zips after 30 days, AI workspace projects untouched for 30 days once installed (90 days if never installed, and never while a change waits for approval), rollback copies after 90 days (the newest change of each project always keeps its copy), file-editor backups after 90 days, trash and spam after 30 days, auto-drafts after 7 days, and logs over 5 MB are rotated.

The database tidies itself too: data nothing points to any more (metadata of deleted posts, comments, terms and users, expired transients) is cleared daily, and tables are compacted weekly. **Tools › Database** shows every table with its owner and row count, optimizes on demand and lists data left by removed plugins. **Tools › Site Health** shows what uses space and has *Clean up now*.

```
rp cleanup --dry-run           # what would go
rp cleanup                     # do it now
rp db optimize --revisions 5   # compact tables, keep 5 revisions per post
rp db leftovers                # data left by removed plugins
rp db plugin-data SLUG --remove
```

## Security checklist

*   Serve the site over HTTPS and keep RustPress on `127.0.0.1` behind the proxy.
*   Run it as its own user (`rustpress`), never as root.
*   Protect the config: `chmod 600 /srv/mysite/rp-config.toml`. It holds the secret key and the database password.
*   On production, consider `disallow_file_edit = true` (no code editing from the admin) and, once set up, `disallow_file_mods = true` (no installing plugins, themes or updates from the admin; `rp update` still works).
*   Install plugins only from sources you trust. PHP, Node and Python plugins run as programs with the `rustpress` user’s rights; JavaScript and WebAssembly plugins are sandboxed. The Plugins screen shows what each plugin may access and flags full access.
*   Keep RustPress updated and keep backups off the server.
*   Use strong administrator passwords. Only administrators can use AI agents.

Everything RustPress does to protect a site is in [Safety and limits](/safety-and-limits/).

## Troubleshooting

| Problem                                                      | Fix                                                                                                                                                                                           |
| ------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| *Address already in use*                                     | Another program uses the port. Without `--listen` RustPress moves to the next free port; with it, pick another port or stop the other program.                                                |
| *Error establishing a database connection*                   | Check user, password, host and that the database exists. Test with `mysql -h HOST -u USER -p DATABASE` or `psql`.                                                                             |
| The site broke after a plugin or theme change                | Open `/rp-admin/safe-mode?on=1` (plugins off and the default theme, for you only), or start with `rp serve --safe-mode`. Changes made by AI agents can be rolled back under **AI › Changes**. |
| Links point to the wrong address                             | Fix `siteurl` and `home` (see Site address above).                                                                                                                                            |
| Uploads fail behind nginx                                    | Raise `client_max_body_size`.                                                                                                                                                                 |
| Emails don’t arrive                                          | **Settings › Email › Send test email** shows the error.                                                                                                                                       |
| *No permission to replace …* when updating                   | The program file belongs to another user: run `sudo rp update`, or move the program into a folder the `rustpress` user owns.                                                                  |
| A plugin shows *Restarted N times for using too much memory* | It probably leaks memory. Ask the QA Tester agent to review it, or deactivate it.                                                                                                             |
| An update went wrong                                         | Put `rp.previous` back and reload (see [Install and update](/install-and-update/)).                                                                                                           |
| An AI chat says *Stopped: the server restarted*              | The server was stopped during a run. Send a message to continue.                                                                                                                              |
| Forgot the admin password                                    | `rp user create newadmin you@example.com 'new-password' administrator --root /srv/mysite`, log in, and reset the old account.                                                                 |

Start with **Tools › Logs**. Settings and environment variables are listed in [Configuration](/configuration/).

---

# Configuration

URL: https://rustpress.witsberry.com/configuration/

> Every rp-config.toml setting and environment variable for RustPress, with databases, connection strings, optional programs and server signals.

This page lists the settings in `rp-config.toml`, the environment variables that override them, and the signals a running server understands. Most sites never need to touch any of these: the setup wizard writes what’s needed.

## The site folder

The site folder (`--root`, `$RP_ROOT`, or the current folder) holds everything:

*   `rp-config.toml`: settings, created on first run with a fresh secret key
*   `rp-content/`: themes, plugins, uploads, logs, the AI workspace and, with SQLite, `database.sqlite`
*   `sdk/`: the plugin SDKs and `PROTOCOL.md`
*   `rp.pid`: the running server’s process ID

## Databases

| Database         | `database_url`                                      |
| ---------------- | --------------------------------------------------- |
| SQLite (default) | `sqlite://rp-content/database.sqlite`               |
| MySQL            | `mysql://user:password@127.0.0.1:3306/wordpress`    |
| MariaDB          | `mariadb://user:password@127.0.0.1:3306/wordpress`  |
| PostgreSQL       | `postgres://user:password@127.0.0.1:5432/wordpress` |

SQLite is right for most sites, including busy ones, and is one file to back up. For MySQL, MariaDB and PostgreSQL the database must already exist. Managed databases connect over TLS with `?sslmode=require` or `?sslmode=verify-full`. New sites name their tables `rp_posts`, `rp_options`…; set `table_prefix = "wp_"` to run on an existing WordPress database.

## Settings in rp-config.toml

| Setting               | Default                | What it does                                                                                                                |
| --------------------- | ---------------------- | --------------------------------------------------------------------------------------------------------------------------- |
| `listen`              | `127.0.0.1:8080`       | Address and port; `--listen` overrides it                                                                                   |
| `database_url`        | SQLite in `rp-content` | See Databases above                                                                                                         |
| `table_prefix`        | `rp_`                  | Table prefix; a WordPress database usually uses `wp_`                                                                       |
| `content_dir`         | `rp-content`           | Themes, plugins, uploads                                                                                                    |
| `secret_key`          | Random                 | Signs logins and encrypts stored keys. Changing it logs everyone out                                                        |
| `disallow_file_mods`  | `false`                | Turn off installing and removing themes and plugins                                                                         |
| `disallow_file_edit`  | `false`                | Turn off the theme and plugin file editors                                                                                  |
| `safe_mode`           | `false`                | Run without plugins, on the default theme                                                                                   |
| `plugin_timeout_secs` | `10`                   | How long a plugin call may take                                                                                             |
| `plugin_memory_mb`    | `512`                  | A plugin service using more memory is restarted and flagged as a likely leak; `0` turns the check off                       |
| `php_binary`          | Found on PATH          | PHP program for PHP plugins                                                                                                 |
| `php_options`         | `[]`                   | Extra php.ini settings, e.g. `["opcache.jit=tracing", "opcache.jit_buffer_size=32M"]`                                       |
| `cache_url`           | Memory                 | Shared cache: `redis://`, `rediss://` (TLS), `valkey://`, `valkeys://`, `memcached://host:11211`                            |
| `queue_workers`       | `2`                    | Background job workers                                                                                                      |
| `background_cron`     | `true`                 | Run scheduled events and jobs inside the server                                                                             |
| `log_max_lines`       | `5000`                 | Lines per log file part                                                                                                     |
| `check_updates`       | `true`                 | Look for new releases twice a day                                                                                           |
| `trusted_proxies`     | `["127.0.0.1", "::1"]` | Proxies whose `X-Forwarded-For` is believed: addresses, ranges (`10.0.0.0/8`) or `private`; `[]` when nothing runs in front |
| `debug`               | `false`                | Extra diagnostics in the log                                                                                                |

Reload the server after editing the file: `sudo systemctl reload rustpress`, or send it `SIGUSR2`.

## Environment variables

| Variable                          | What it does                                                      |
| --------------------------------- | ----------------------------------------------------------------- |
| `RP_ROOT`                         | Site folder (instead of `--root`)                                 |
| `RP_DATABASE_URL`                 | Database (instead of `database_url`)                              |
| `RP_CACHE_URL`                    | Cache server (instead of `cache_url`)                             |
| `PORT`                            | Listen on `0.0.0.0:$PORT` (container platforms set it)            |
| `RP_LISTEN`                       | Address to listen on                                              |
| `RP_SECRET_KEY`                   | Secret key, 32 characters or more                                 |
| `RP_TRUSTED_PROXIES`              | Comma-separated proxies, ranges or `private`                      |
| `RP_TABLE_PREFIX`                 | Database table prefix                                             |
| `RP_FCGI_THREADS`                 | FastCGI worker threads (default 4 per CPU)                        |
| `RP_SAFE_MODE=1`                  | Safe mode                                                         |
| `RP_PHP`                          | PHP program for plugins                                           |
| `RP_PHP_PER_CALL=1`               | Start PHP for every plugin call instead of keeping it running     |
| `RP_TAILWIND`                     | Path to a `tailwindcss` program (offline servers)                 |
| `RP_LOG_QUERIES=1`                | Print every database query                                        |
| `RP_UPDATE_API`, `RP_UPDATE_REPO` | Where update checks look (default: GitHub, `Witsberry/RustPress`) |

## Site options you may want

Set these with `rp option set NAME VALUE`:

*   `rp_page_cache` (`0` turns the page cache off) and `rp_page_cache_ttl` (seconds, default 600)
*   `rp_minify` (`0` turns HTML and CSS minification off)
*   `siteurl` and `home` (the site’s address)

## Optional programs

| For                                 | Install                                                                                                                        |
| ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| Plugins written in PHP              | `php` 8.1 or later (`sudo apt install php-cli`)                                                                                |
| Plugins written in JavaScript       | Nothing for sandboxed plugins; Node 18 or later for `http` services                                                            |
| Plugins written in Python           | `python3`                                                                                                                      |
| Tailwind themes                     | Nothing: the Tailwind tool is downloaded once and checked                                                                      |
| AI agents through Claude Code       | Claude Code, logged in as the user RustPress runs as. It runs with only RustPress’s tools and none of the server’s environment |
| Building Rust plugins on the server | Rust with the `wasm32-unknown-unknown` target, and bubblewrap; builds are refused without the sandbox                          |

## Signals

| Signal                 | Effect                                                           |
| ---------------------- | ---------------------------------------------------------------- |
| `TERM`, `INT` (Ctrl+C) | Stop: finish requests in progress, stop plugin programs, exit    |
| `USR2`                 | Restart without downtime, with the new program file and settings |

Every command is in the [Command reference](/command-reference/).

---

