# WordPress + MySQL on Compute

Source: https://docs.quake.ai/resources/iac-templates/wordpress-mysql
Markdown: https://docs.quake.ai/resources/iac-templates/wordpress-mysql.md

---

# WordPress + MySQL on compute

This pattern composes Compute, Network, and Block Storage.

## What this template does

Provisions a WordPress application server and a dedicated MySQL database instance:

- WordPress instance with Nginx and PHP-FPM, installed and wired to the database by cloud-init
- MySQL (MariaDB) instance on a private network (no public access), with its data directory on the attached volume (mounted at `/var/lib/mysql` on `/dev/sdb`)
- Block storage volume for the MySQL data directory
- Security groups restricting MySQL access to the private subnet only
- Floating IP for public WordPress access

On apply, cloud-init installs MariaDB and creates the `db_name` database and `db_user` role on the MySQL instance, then installs Nginx, PHP-FPM, and WordPress on the web instance and points `wp-config.php` at the database. Reach the WordPress installation screen at the floating IP once cloud-init finishes. Set `db_password` to a strong value when you apply; the template ships no default password.

## Parameters

| Parameter | Description | Default |
| --- | --- | --- |
| `key_name` | SSH keypair name (must already exist in your project) | required |
| `wp_flavor` | WordPress instance size | `s1a.small` |
| `db_flavor` | MySQL instance size | `m2a.large` |
| `db_volume_size` | MySQL volume in GB | `20` |
| `image_name` | Operating system image | `Ubuntu-24.04` |
| `wp_domain` | WordPress site domain | No default |
| `db_name` | WordPress database name | `wordpress` |
| `db_user` | WordPress database user | `wordpress` |
| `db_password` | Password for the database user (required, no default) | _none_ |
| `external_network` | External network for router gateway and floating IP | `PublicStatic` |
| `private_cidr` | Address range for the private subnet between WordPress and MySQL | `192.168.10.0/24` |

## When to use this pattern

Run WordPress and MySQL on separate compute instances with block-backed boot disks. Choose [Self-Managed PostgreSQL](/resources/iac-templates/self-managed-postgres) for a Postgres-only database host, [MySQL/MariaDB Database](/resources/iac-templates/mysql-database) for a standalone MySQL-compatible target without the WordPress application tier, or [Full-Stack Application](/resources/iac-templates/full-stack-app) when you need web, app, and database tiers with distinct subnets.

## Estimated cost

<PricingCompanion
  components={[
    { kind: "template", slug: "wordpress-mysql", required: true },
  ]}
/>

## Template source

<TemplateSource slug="wordpress-mysql" />

<TemplateVariations base="wordpress-mysql" />

<TemplateResourceMap template="wordpress-mysql" format="opentofu" />

## Customize this pattern

- [Customize a template's image and flavor](/docs/automation/how-to/customize-template-image-flavor)
- [Add a block volume to a template](/docs/automation/how-to/add-volume-to-template)
- [Parameterize a template with a tfvars file](/docs/automation/how-to/parameterize-template-tfvars)

## See also

- [Deploy the WordPress + MySQL template with OpenTofu](/resources/deployments/deploy-wordpress-mysql-template)
- [Simple VM template](/resources/iac-templates/simple-vm)
- [Self-Managed PostgreSQL template](/resources/iac-templates/self-managed-postgres)
