---
title: "WordPress CLI (WP-CLI): Install, Commands, Automation"
description: "WordPress CLI is the command-line interface for WordPress. You'll install it, authenticate, and execute administrative tasks from the command line."
url: https://www.activepieces.com/blog/wordpress-cli-wp-cli-install-commands-automation
updated: 2026-12-06
---

> Every page on www.activepieces.com is available as markdown: add `.md` to the URL, or send `Accept: text/markdown`. Site index: https://www.activepieces.com/llms.txt

# WordPress CLI (WP-CLI): Install, Commands, Automation

By Bethany Morrison · December 6, 2026 · 14 min read · Filed under [Automation tutorials](https://www.activepieces.com/blog/category/automation-tutorials)

**Summary**

WP-CLI is the free, official command-line interface for WordPress, running on your server with no API keys, authentication, or rate limits.

- Seven causes account for most WP-CLI production errors, each with recognisable messages.
- Four of the ten most-used commands are destructive and need backups first.
- SSH access and command-line PHP are required for WP-CLI on shared hosting.

WP-CLI **is the free, official command-line interface** for WordPress.

It has no API key, no tiers, no per-unit pricing and no rate limits, because it **runs on your server** and uses the site's own access rather than a vendor's gateway, which also means it slots easily into schedulers and [Activepieces](https://www.activepieces.com) flows that already run on your own infrastructure.

Everything here comes from wp-cli.org, checked on 2026-12-06.

## Understand WP-CLI as command-line tool

### What WP-CLI does

If you would rather skip the admin screen, WP-CLI lets you manage a WordPress site from a terminal instead. You can update core, install and activate plugins, create users, search and replace in the database, and export content, all as commands.

![Activepieces workflow builder displaying an AI blog writing automation with OpenAI and WordPress integration steps.](https://ap-marketing-media.fra1.cdn.digitaloceanspaces.com/uploads/ca000698-c716-45d3-916f-88df50a3761a/spotify-automation-ways-to-set-it-up-2026-guide-fa565726.webp)

### WP-CLI limits and cost trade-offs

The trade-off is that **it has no hosted endpoint**. It won't answer a request from another machine, and it doesn't sign anyone in over the network. Your limits are those of the server: its CPU, its memory and how many jobs you run at once.

| | Where it runs | How it authenticates | Cost model | Rate limits |
|---|---|---|---|---|
| WP-CLI | On the WordPress server | The server user's own access to the site | Free | None set by the tool; server resources only |
| WordPress REST API | Over HTTP, on the site | Credentials sent with each request, such as application passwords or cookies | Included with WordPress | Whatever your host or security plugins impose |
| Hosted automation service | On the vendor's cloud | Connection you grant to the site | Set by the vendor's plan | Set by the vendor's plan |

### When you want the REST API instead

Choose the REST API when the caller is not on the server. That means a separate application, a browser front end, or a service in another location that needs to read or write site data over HTTP.

It's built into WordPress, so it needs no installation, but every request must carry credentials and can be filtered by your host.

If it must reach in from outside, the REST API is the right door, and [Activepieces](https://www.activepieces.com), whose MIT-licensed core has 25,885 GitHub stars you can read the source behind, can sit on top of it.

## Install WP-CLI on macOS, Linux and Windows

Install WP-CLI on the machine that holds the WordPress files, because it runs there and borrows the site's own access instead of knocking from outside like the REST API.

On macOS, Homebrew is the shortest route:

```bash
brew install wp-cli
```

On Linux, download the phar, confirm PHP can run it, make it executable, then move it onto your PATH as `wp`:

```bash
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
php wp-cli.phar --info
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
```

On shared hosting without `sudo`, put the file in a directory you own and add that directory to PATH instead.

### Windows install

On Windows, the handbook treats the environment as more limited than Unix-like systems. The route I'd take is Windows Subsystem for Linux: open a Linux shell and follow the Linux steps exactly.

### Verify the WP-CLI install with wp --info

Run this in a new terminal:

```bash
wp --info
```

When the install is healthy, it prints the PHP binary in use, the PHP version, the WP-CLI version and the directory it will read config from.

If it reports "command not found", the file isn't on your PATH, so fix that before doing anything else.

## How WP-CLI connects to a WordPress site

There is no login, no API key and no token. WP-CLI runs as whichever server user you are, loads WordPress from a directory on disk, and inherits whatever that site is already allowed to do.

![Person inside a house beside a visitor holding an unneeded token](https://ap-marketing-media.fra1.cdn.digitaloceanspaces.com/uploads/12ed554a-46c9-494a-a3a5-de6e8904170a/wordpress-cli-wp-cli-install-commands-automation-a47bcb38.webp)

### Run WP-CLI as the right user

Whoever you are logged in as is who WP-CLI acts as, so the account matters.

If you run it as root, WP-CLI refuses and warns you, because a root-run command can create files the web server user then can't write to, such as cache or upload directories.

![Small worker below a shelf stacked by an oversized hand](https://ap-marketing-media.fra1.cdn.digitaloceanspaces.com/uploads/f1e932c6-f3ed-435f-8f79-51de9e359240/wordpress-cli-wp-cli-install-commands-automation-53e748e1.webp)

Run commands as the account that owns the site's files. On a typical server that is the web user or a dedicated site user:

```
sudo -u www-data -- wp core version
```

Swap `www-data` for your site's actual owner. Only use `--allow-root` in a throwaway container where file ownership doesn't matter.

### Target a site with WP-CLI --path and --url

Start in the current directory or anywhere above WordPress and WP-CLI finds it on its own. If you are elsewhere, `--path` names the folder that holds `wp-config.php`.

On a multisite install, or any setup where several domains share one codebase, `--url` selects which site the command applies to.

```
wp --path=/var/www/example.com/public_html --url=https://example.com option get siteurl
```

If you must act as a particular WordPress account, `--user` sets it by ID, login or email. Without it, commands run with no logged-in user, which is fine for reading options and wrong for anything that checks capabilities.

![Activepieces workflow builder with a Google Calendar to Gmail automation showing a failed run due to authentication errors.](https://ap-marketing-media.fra1.cdn.digitaloceanspaces.com/uploads/5da2b7cb-ef3f-4707-8861-f709ff3c97bf/automate-gemini-4-carbon-api-setup-limits-pricin-f7237c4b.webp)

### Wp-cli.yml and environment variables

Put flags in a `wp-cli.yml` file in the project root:

```
path: public_html
url: https://example.com
```

When settings conflict, the order is fixed: flags typed on the command line win, then `wp-cli.local.yml`, then the project `wp-cli.yml`, then the user-level file at `~/.wp-cli/config.yml`. Variables use the `WP_CLI_` prefix, for example `WP_CLI_PATH`.

### Run WP-CLI on remote sites over SSH

**You don't need to log in first**. `--ssh` runs the command on another host, and aliases in `wp-cli.yml` give each site a short name:

```
@production:
 ssh: deploy@example.com/var/www/example.com/public_html
 url: https://example.com
```

```
wp @production core version
```

To confirm everything is wired up, run these two. Each should print a real value, not an error:

```
wp core version
wp option get siteurl
```

## Run WP-CLI's ten most-used commands

**Four of the ten commands that cover most day-to-day WordPress work change or erase data, so run `wp db export` before any of those.** Check the table for what each command is for and which ones can't be undone.

| Command | Purpose | Destructive |
|---|---|---|
| `wp core update` | Update WordPress itself | Yes |
| `wp plugin install` / `update` | Add or upgrade plugins | Yes, on update |
| `wp theme list` | Show installed themes | No |
| `wp user create` | Add an account | No |
| `wp post create` | Add a post | No |
| `wp db export` | Dump the database to a file | No |
| `wp search-replace` | Rewrite strings in the database | Yes |
| `wp cache flush` | Clear the object cache | No, but cached data is lost |
| `wp cron event run` | Fire scheduled events now | Depends on the event |
| `wp option get` / `update` | Read or change a setting | Yes, on update |

```
wp db export backup.sql
wp core update
wp plugin list
wp plugin install akismet --activate
wp plugin update --all
wp theme list
```

```
wp user create editor1 editor1@example.com --role=editor
wp post create --post_title="Release notes" --post_status=draft
```

Publishing posts, or reacting when new content lands somewhere else, is the one job here that doesn't need the server's shell.

Activepieces has a WordPress integration for it, and you can read its source in the MIT-licensed core: it is one of the 751 integrations in the open source monorepo under the `packages/pieces/community` directory, where roughly 60% are community-contributed.

Core updates, `wp search-replace` and anything touching the database stay with WP-CLI.

```
wp search-replace 'http://old.example' 'https://new.example' --dry-run
wp search-replace 'http://old.example' 'https://new.example'
```

Run with `--dry-run` and it reports what would change without writing anything. Skip it and the replacement is permanent, which is why the export comes first.

```
wp cache flush
wp cron event run --due-now
wp option get blogname
wp option update blogname "New name"
```

Flushing the cache is recoverable because it rebuilds itself. `option update` overwrites the stored value, so note the old one with `option get` first.

## Fix common WP-CLI production errors

When WP-CLI fails, **seven causes account for most of it**, each with a recognisable message and a short fix, and the table below maps one to the other.

The wording of messages can shift between releases, so match on the gist rather than the exact string.

| Message | Cause | Fix |
|---|---|---|
| `This does not seem to be a WordPress installation.` | WP-CLI is running from a directory with no `wp-config.php` above it | Pass `--path=/full/path/to/site`, or `cd` into the site first |
| `Error establishing a database connection` | Wrong credentials or host in `wp-config.php`, or the database server is down | Check the `DB_*` constants and confirm the database service is running |
| `Allowed memory size ... exhausted` | The CLI's PHP memory limit is too low for the job | Run with `php -d memory_limit=512M $(which wp) ...` or raise `WP_CLI_PHP_ARGS` |
| `YIKES! It looks like you're running this as root.` | WP-CLI refuses root by default because it loads site code | Run as the site's file owner, for example `sudo -u www-data wp ...` |
| Syntax errors or version-related fatals | The CLI's PHP binary differs from the web server's | Run `wp --info` and call the matching PHP binary explicitly |
| White screen or fatal from a plugin or theme | Broken code loads on every command | Add `--skip-plugins` or `--skip-themes` |
| Command stops partway on a large job | A time or resource limit on the host or shell session | Batch the work, or run it under `screen`, `tmux` or `nohup` |

### WP-CLI path, user and database errors

When you see "not a WordPress installation", it almost always means the wrong working directory, so set `--path` explicitly in scripts rather than relying on where the job starts.

On the database error, the fault is the site's own: WP-CLI reads the same credentials the web server does, so if the site is down, so is the command.

On root, you can override with `--allow-root`, but the safer fix is running as the correct user.

### WP-CLI memory and PHP version problems

A site can run fine in the browser and still exhaust memory in a bulk import, because the command line often uses a different `php.ini` from the web server.

### WP-CLI errors from broken plugins and themes

When a plugin throws a fatal error on load, **every WP-CLI command goes down with it**, including the ones you need to deactivate it.

Add `--skip-plugins` to bypass all plugins, or `--skip-plugins=plugin-name` for one, then run `wp plugin deactivate plugin-name`. `--skip-themes` does the same for the active theme. Skipping plugins also skips any commands those plugins register.

### WP-CLI timeouts on large jobs

A timeout on a long job usually comes from your SSH session dropping or a host-level cap, because WP-CLI itself doesn't impose the web server's execution limit.

Process large sets in batches, and start long runs inside `tmux` or `screen` so a lost connection doesn't kill them.

## Run WP-CLI in cron and CI, and where Activepieces fits

Schedule WP-CLI from system cron or a CI runner, and give every job an absolute `--path`, because a scheduled shell has no working directory to guess from.

### Run WP-CLI in system cron and CI

When a job starts under cron, the environment is minimal: a short `PATH`, no login profile, often a different user from the one you tested as. A command that works in your terminal can fail silently there.

![A wall clock above a terminal showing a short PATH line, next to a nearly empty second terminal with a bare prompt: the…](https://ap-marketing-media.fra1.cdn.digitaloceanspaces.com/uploads/f7631cc9-a611-4654-a0de-515a9c497109/wordpress-cli-wp-cli-install-commands-automation-b44f9a19.webp)

The list below shows what a job has to state for itself, and the failures it prevents.

- An absolute `--path` to the WordPress root, so the job doesn't depend on the current directory.
- The full path to the `wp` binary, since cron's `PATH` may not include it.
- The right system user, so files it writes aren't owned by root.
- Output redirected to a log file, or failures vanish.
- The CLI PHP version, which can differ from the one the web server runs.

Separately, WordPress's own scheduler fires only when a page is requested. To run it from the system clock, set `DISABLE_WP_CRON` to true in `wp-config.php` and call `wp cron event run --due-now` from real cron every few minutes.

### When a no-code workflow is enough

If a job starts from an event rather than a server, [Activepieces](https://www.activepieces.com/pricing) has a WordPress integration that suits it: creating a post when a form is submitted, say.

On Activepieces' pricing page, Free is listed at $0 per month, Plus at $20 and Team at $200.

Those tiers step up with monthly credits, so a workflow that fires on every submission has a cost that grows with traffic. WP-CLI in cron costs nothing per run.

![What Activepieces plans cost each month](https://ap-marketing-media.fra1.cdn.digitaloceanspaces.com/uploads/8603add8-10c8-48b1-a9c7-a66333cfd967/wordpress-cli-wp-cli-install-commands-automation-2d9caeef.svg "Source: Activepieces")

It doesn't replace WP-CLI for core updates, database work or anything that needs the server's filesystem. Use the integration for form-to-post jobs, and cron for the rest.

## Frequently asked questions

### Is WP-CLI free?

Yes, WP-CLI is free, open-source software with no API key, no tier and no per-command charge.

The only costs are the ones you already pay for: the server it runs on and the hosting plan that gives you shell access. If a vendor quotes you a price for "WP-CLI access," you're paying for the hosting feature, not the tool.

### Does WP-CLI work on shared hosting?

It works on shared hosting only if your plan includes SSH access and a command-line PHP. Many hosts preinstall it, so check by running `wp --info` after you log in.

If the host offers no shell, there's nothing to run the tool in, and no setting inside WordPress will change that. Check your plan's feature list before you budget time for automation.

![A workflow automation with Google Calendar trigger and Gmail send email action, showing a failed test run with…](https://ap-marketing-media.fra1.cdn.digitaloceanspaces.com/uploads/8dec613e-44ab-4c1f-b905-34a8dfe349a7/set-up-factory-ai-automation-in-2026-and-know-it-42d01395.webp)

### Is WP-CLI the same as the WordPress REST API?

No. The REST API is a set of HTTP endpoints that remote clients call with credentials.

Running on the server itself, WP-CLI loads WordPress directly, using the site's own access instead of a token you issue. That's why it needs no authentication setup, and why it can't be called from a machine that has no shell on the server.

For a remote service that has to reach your site over the network, the REST API remains the interface built for it.

To update WP-CLI itself, run `wp cli update`. To see whether a newer release exists before you commit, run `wp cli check-update`.

If your host installed WP-CLI in a location your account can't write to, the update will fail with a permissions error. You'll need the host to update it, or a copy you install in your own directory.

Can you run WP-CLI on Windows without WSL? Not reliably. The project's documentation treats Windows as having limited support, and WSL, the Linux environment built into Windows, is the safer route.

Some commands lean on tools that behave differently outside a Unix-style shell, so a native setup can work for simple tasks and then fail on the first command that shells out.

## Related reading

- [Shopify CLI: Install, Set Up, Commands (2026 Guide)](https://www.activepieces.com/blog/shopify-cli-install-set-up-commands-2026-guide)
- [GitLab CLI (glab) Install, Login and Commands in 2026](https://www.activepieces.com/blog/gitlab-cli-glab-install-login-and-commands-in-2026)
- [What Is the AWS CLI? Install, Sign In, Commands (2026)](https://www.activepieces.com/blog/what-is-the-aws-cli-install-sign-in-commands-2026)

## References

- [Activepieces](https://www.activepieces.com/pricing)
