Quickstart cipi.yml Web panel API MCP Ecosystem Guides Docs GitHub Telegram channel
  1. Home
  2. Guides
  3. WordPress from Git with zero-downtime deploys on your own VPS
PHP, WordPress & e-commerce

WordPress from Git with zero-downtime deploys on your own VPS

Run WordPress like an application — code in Git, atomic releases with rollback, uploads and wp-config.php kept outside the releases, Bedrock, WP-CLI, real cron and caching, with Cipi.

By Updated 4 min read

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: --wordpressWordPress as a custom app
CodeIn GitUploaded, changed from wp-admin
DeployA new release, switched in one stepIn place
RollbackOne commandA backup
Plugins and updatesIn Git or Composer, then a deployFrom 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/
bash
# .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#

bash
# 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
A WordPress app from Git
$ 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_PREFIXThe database made with the app
AUTH_KEY … NONCE_SALTThe eight keys and salts, generated
WP_HOME, WP_SITEURL, WP_ENVIRONMENT_TYPEThe domain, on https://, and the environment
DISALLOW_FILE_MODS, AUTOMATIC_UPDATER_DISABLEDtrue: the code comes from Git
DISABLE_WP_CRONtrue: cron runs from the crontab, every minute
WP_DEBUG, WP_DEBUG_LOG, WP_DEBUG_DISPLAYfalse: 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#

bash
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:

bash
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:

WhatClassicBedrock
A pluginCommit it to wp-content/plugins, or composer require wpackagist-plugin/<name> with a composer.json at the rootcomposer require wpackagist-plugin/<name>
WordPress itselfUpdate locally, commitcomposer update roots/wordpress
Thengit pushgit 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#

bash
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#

Step 1 of 6Code

Put the site's files in a repository in one of the two layouts above, without wp-config.php and without the uploads.

9. Cron, caching, backups#

  • Cron. wp-cron.php runs 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 on has Nginx answer anonymous visitors without PHP (the guide).
  • Object cache. sudo cipi cache blog object on gives the site a Valkey of its own and writes the WP_REDIS_* lines (classic layout; on Bedrock add them to config/application.php).
  • Backups. ~/shared (uploads, .env) and the database:
bash
sudo cipi backup profile add blog-nightly --scope=all --cron='0 2 * * *' --keep-days=14 --dest=s3 --encrypt

10. When a deploy goes wrong#

bash
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:

bash
sudo cipi app deploy-config blog --predeploy-snapshot

Troubleshooting#

ProblemFix
The deploy stops at wp-settings.php not foundThe repository has no WordPress core (classic), or roots/wordpress is missing from composer.json (Bedrock)
Error establishing a database connectionCheck DB_* with sudo cipi app env blog. DB_HOST is 127.0.0.1:3306
A plugin is missing after a deployIt was installed outside Git. Add it to the repository or to Composer
Images are broken after a moveUploads go in ~/shared/wp-content/uploads (Bedrock: ~/shared/web/app/uploads), owned by the app user
The old domain keeps coming backWP_HOME and WP_SITEURL follow sudo cipi app edit blog --domain=…; links stored in posts need wp search-replace
The white screenWP_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.

Try it on your own server

Free and open source. One command on a fresh Ubuntu 24.04 or 26.04 VPS.

wget -O - https://cipi.sh/setup.sh | bash
Read the quickstart