CLI / Terminal Access
WP-CLI is the official command-line interface for WordPress. It allows you to manage WordPress installations without using a web browser - update plugins, export databases, manage users, and much more. This is the preferred method for developers, agencies, and anyone with SSH access to their server.
Prerequisites
- SSH access to your server
- WP-CLI installed (most modern hosts include it)
- Basic command line knowledge
Installing CLI
Setting up the environment.
Method 1: WP-CLI (Direct)
Download: curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
Make Executable: chmod +x wp-cli.phar
Move: sudo mv wp-cli.phar /usr/local/bin/wp
Verify: wp --info
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wpMethod 2: Docker (For wp-env)
Required for the wp-env workflow.
Mac: brew install --cask docker or download Docker Desktop.
Windows: Download Docker Desktop for Windows.
Linux: sudo apt-get install docker.io
Start Docker and verify: docker -v
docker -v
docker-compose -vMethod 3: wp-env (Wrapper)
Once Docker is running, install the wrapper: npm -g i @wordpress/env
npm -g i @wordpress/envVerification Checklist
- wp --info works
- wp-env start launches site at localhost
- Database verification: wp post list returns content
Pro Tips
- Use `--dry-run` with search-replace to test before executing
- Use `wp-env run cli wp shell` for an interactive PHP shell with WP loaded
- Alias `wp` to `wp-env run cli wp` for local dev convenience