WordPress is usually run from its dashboard: plugins installed with a click, updates applied on the live site, files changed in place. That is fine for many sites. A team that reviews code, tests updates on staging and wants to undo a bad deploy in seconds needs something else: WordPress kept in Git and deployed as releases.
Cipi has an app type for exactly that. This guide takes a site from repository to production.
This guide: --wordpress | WordPress as a custom app | |
|---|---|---|
| Code | In Git | Uploaded, changed from wp-admin |
| Deploy | A new release, switched in one step | In place |
| Rollback | One command | A backup |
| Plugins and updates | In Git or Composer, then a deploy | From wp-admin |
1. Prepare the repository#
Pick the layout your project has. Both work.
Classic. WordPress itself at the root of the repository, with your themes and plugins:
blog/
├── index.php wp-settings.php wp-load.php …
├── wp-admin/ wp-includes/
└── wp-content/
├── themes/my-theme/
└── plugins/# .gitignore
/wp-config.php
/wp-content/uploads/
/wp-content/cache/
/wp-content/upgrade/Leave wp-config.php out: Cipi writes its own and links it into every release.
Bedrock. The roots.io layout, where WordPress and plugins are Composer packages:
shop/ ├── composer.json composer.lock ├── config/application.php └── web/ # the document root ├── app/themes/my-theme/ └── wp/ # installed by Composer, not in Git
Bedrock's own .gitignore is already right: .env, web/wp and web/app/uploads stay out of Git.
2. Create the app#
# Classic sudo cipi app create --wordpress --user=blog --domain=blog.example.com \ --repository=git@github.com:acme/blog.git --branch=main # Bedrock sudo cipi app create --wordpress --user=shop --domain=shop.example.com \ --repository=git@github.com:acme/shop.git --branch=main --docroot=web
$ sudo cipi app create --wordpress --user=blog --domain=blog.example.com --repository=git@github.com:acme/blog.git
In one command you get the Linux user, a PHP-FPM pool, the Nginx site, a MySQL/MariaDB database named like the app, and ~/shared with everything that must survive a deploy:
/home/blog/shared/ ├── .env # DB_*, the eight salts, WP_HOME, WP_SITEURL ├── wp-config.php # reads that .env (classic layout) └── wp-content/uploads/
The .env is ready, as a Laravel app's is: nothing to edit before the first deploy.
In the .env | |
|---|---|
DB_NAME, DB_USER, DB_PASSWORD, DB_HOST, DB_PREFIX | The database made with the app |
AUTH_KEY … NONCE_SALT | The eight keys and salts, generated |
WP_HOME, WP_SITEURL, WP_ENVIRONMENT_TYPE | The domain, on https://, and the environment |
DISALLOW_FILE_MODS, AUTOMATIC_UPDATER_DISABLED | true: the code comes from Git |
DISABLE_WP_CRON | true: cron runs from the crontab, every minute |
WP_DEBUG, WP_DEBUG_LOG, WP_DEBUG_DISPLAY | false: errors are neither shown nor logged until you ask |
Save the summary: it is shown once. Add the deploy key to the repository as a read-only key, or let Cipi do it with a provider token.
A theme with a build step takes one more flag: --node-build='npm ci && npm run build'.
3. Deploy#
sudo cipi deploy blog
The deploy clones the branch into a new release, links wp-config.php and the uploads, runs composer install when there is a composer.json, runs your build, checks that the release has a WordPress to serve, and only then points the site at it. Visitors get the old release until that instant and the new one after it.
Now open https://blog.example.com/wp-admin/install.php (after step 4) and run WordPress's installer: site title, admin user. The database credentials are already in place.
4. HTTPS#
Point the domain at the server, then:
sudo cipi ssl install blog
WP_HOME and WP_SITEURL were written with https:// from the start, so there is nothing to change in WordPress.
5. Push to deploy#
The create summary shows a webhook URL and a secret. Add them to the repository (GitHub: Settings → Webhooks, content type JSON) and every push to the branch is a deploy. With a provider token saved, the webhook is already there. No plugin is needed in WordPress.
6. Plugins, themes and core updates#
All three arrive the way your own code does:
| What | Classic | Bedrock |
|---|---|---|
| A plugin | Commit it to wp-content/plugins, or composer require wpackagist-plugin/<name> with a composer.json at the root | composer require wpackagist-plugin/<name> |
| WordPress itself | Update locally, commit | composer update roots/wordpress |
| Then | git push | git push |
wp-admin shows no installer and no update button. That is deliberate: a plugin added there would live in one release and vanish with the next deploy.
Database changes a plugin makes on update (its own "upgrade routine") run when an administrator next loads wp-admin, or at once with wp core update-db and the plugin's own WP-CLI command.
7. WP-CLI#
sudo cipi package install wp-cli sudo su - blog wp plugin list wp user create editor editor@example.com --role=editor wp search-replace 'http://old.example.com' 'https://blog.example.com' --dry-run
wp works on the live release from any folder, and runs on the PHP version the app runs on.
8. Moving an existing site in#
Put the site's files in a repository in one of the two layouts above, without wp-config.php and without the uploads.
The app, its empty database and ~/shared.
Export on the old host (wp db export site.sql, or phpMyAdmin), copy the file to the server, then as the app user: wp db import site.sql. If the table prefix is not wp_, set DB_PREFIX in sudo cipi app env blog.
Copy the old wp-content/uploads into ~/shared/wp-content/uploads (rsync or SFTP, as the app user).
If the domain changes: wp search-replace 'https://old.example.com' 'https://blog.example.com'.
Then HTTPS, and switch the DNS.
9. Cron, caching, backups#
- Cron.
wp-cron.phpruns every minute from the app's crontab, so scheduled posts and WooCommerce jobs do not wait for a visitor. - Page cache.
sudo cipi cache blog onhas Nginx answer anonymous visitors without PHP (the guide). - Object cache.
sudo cipi cache blog object ongives the site a Valkey of its own and writes theWP_REDIS_*lines (classic layout; on Bedrock add them toconfig/application.php). - Backups.
~/shared(uploads,.env) and the database:
sudo cipi backup profile add blog-nightly --scope=all --cron='0 2 * * *' --keep-days=14 --dest=s3 --encrypt
10. When a deploy goes wrong#
sudo cipi deploy blog --rollback
The site is back on the previous release in one step. For deploys that change the database — a plugin update with a migration — take a snapshot first, so the data can go back too:
sudo cipi app deploy-config blog --predeploy-snapshot
Troubleshooting#
| Problem | Fix |
|---|---|
| The deploy stops at wp-settings.php not found | The repository has no WordPress core (classic), or roots/wordpress is missing from composer.json (Bedrock) |
| Error establishing a database connection | Check DB_* with sudo cipi app env blog. DB_HOST is 127.0.0.1:3306 |
| A plugin is missing after a deploy | It was installed outside Git. Add it to the repository or to Composer |
| Images are broken after a move | Uploads go in ~/shared/wp-content/uploads (Bedrock: ~/shared/web/app/uploads), owned by the app user |
| The old domain keeps coming back | WP_HOME and WP_SITEURL follow sudo cipi app edit blog --domain=…; links stored in posts need wp search-replace |
| The white screen | WP_DEBUG=true and WP_DEBUG_LOG=true in sudo cipi app env blog, then read wp-content/debug.log; turn them off after |
The reference page, with every option: WordPress apps.
Questions
Can I still install plugins from wp-admin?
Not on this app type. A deploy replaces the release whole, so a plugin added from the dashboard would be gone at the next one — the installers are switched off (DISALLOW_FILE_MODS). Add the plugin to the repository or to composer.json and deploy. For a WordPress run from its dashboard, use a custom app.
What happens to my uploads when I deploy?
Nothing. wp-content/uploads lives in ~/shared and is linked into every release.
Do I have to use Bedrock?
No. A classic repository with WordPress at its root works the same way. Bedrock is supported with --docroot=web.
Where do the database password and the salts live?
In ~/shared/.env, generated at creation. Cipi's wp-config.php reads them; Bedrock reads the same file itself. Edit with sudo cipi app env blog.
How do I roll back?
sudo cipi deploy blog --rollback points the site at the previous release in one step. The database is not rolled back — take a snapshot before deploys that change it.
Does WP-CLI work with releases?
Yes. After sudo cipi package install wp-cli, wp run as the app's user works on the live release from any folder, on the app's own PHP version.
Can I deploy without Git, over SFTP?
Not with this type: each deploy is a release of the repository. An SFTP-only site is a custom app.