WP-CLI (WordPress Command Line Interface) allows you to manage your WordPress site efficiently from the terminal, such as updating cores, installing plugins/themes, managing users, and more. Since it’s already installed (as verified in File Manager), you can jump straight into using it. The key is accessing the cPanel Terminal and navigating to your WordPress root directory.
Step 1: Access the cPanel Terminal
- Log in to your cPanel account via your hosting provider’s dashboard (usually at yourdomain.com/cpanel).
- In the cPanel sidebar, scroll down to the Advanced section.
- Click on Terminal (it may be labeled as “SSH Access” or “Terminal” depending on your host; if it’s not visible, ensure your hosting plan supports shell access).
- A new terminal window or tab will open, giving you a command-line shell (likely Bash). You’ll see a prompt like [username@server ~]$.
Step 2: Navigate to Your WordPress Installation Directory
- Your WordPress files are typically in the public_html folder (or a subdomain folder like public_html/blog if it’s not the main site).
- In the terminal, type the following command to change directories (replace public_html with your actual path if different):
text
cd public_html- Press Enter. You can confirm you’re in the right place by running ls (lists files) and looking for WordPress core files like wp-config.php, wp-content/, or index.php.
- If your site is in a subdirectory (e.g., public_html/myblog), use:
text
cd public_html/myblog
Step 3: Verify WP-CLI Installation and Configuration
- Once in your WordPress directory, run this command to check if WP-CLI is working and see its version/info:
text
wp --info- This should output details like the WP-CLI version, WordPress version, and PHP details. If it works, great! If you get a “command not found” error, WP-CLI might not be in your PATH—skip to the Troubleshooting section below.
- Test basic connectivity by checking your site’s core version:
text
wp core version- It should display your current WordPress version (e.g., “6.4.2”).
WP-CLI automatically detects your wp-config.php file in the current directory, so no extra setup is needed for database credentials.
Step 4: Run Your First Basic Commands
Start with simple, safe commands to get comfortable. Always run wp without arguments first to see a help menu:
wp help
Here are beginner-friendly examples (run these in your WordPress directory):
- Check site health and status:
text
wp doctor check --all- This scans for common issues like outdated plugins.
- List installed plugins:
text
wp plugin list- Shows all plugins with status (active/inactive).
- Install and activate a plugin (e.g., Yoast SEO):
text
wp plugin install yoast-seo --activate - Update WordPress core:
text
wp core update- Prompts for confirmation; use –yes to skip (e.g., wp core update –yes).
- List themes:
text
wp theme list - Create a new post (via command; edit later in WP admin):
text
wp post create --post_title="My First CLI Post" --post_content="Hello from WP-CLI!" --post_status=publish --post_type=post - Get help for any command:
text
wp <command> help- E.g., wp plugin help for plugin-specific options.
Step 5: Best Practices and Tips
- Always back up first: Before major changes (e.g., updates), use wp db export backup.sql to export your database, or back up via cPanel’s File Manager/Backup tool.
- Run as the correct user: Ensure you’re not running as root; cPanel terminals are user-level.
- Aliases for speed: Add shortcuts in your ~/.bashrc file (edit with nano ~/.bashrc), e.g., alias w=’wp’, then run source ~/.bashrc to reload.
- Verbose output: Add –verbose to any command for more details (e.g., wp core update –verbose).
- Multisite? If your site is a WordPress Multisite, add –url=your-subsite.com to target specific sites.
- Exit terminal: Type exit when done.
Troubleshooting Common Issues
- “wp: command not found”: WP-CLI might be installed locally. Find its path in File Manager (often ~/bin/wp or ~/.local/bin/wp), then run it as ./bin/wp (if in the dir) or add to PATH: export PATH=$PATH:~/bin (add to ~/.bashrc for permanence).
- Permission errors: Run wp core download –allow-root if needed (rare in cPanel), or check file ownership with ls -la.
- PHP errors: If WP-CLI uses a different PHP version, specify it: /usr/local/bin/php wp –info (ask your host for the path).
- No database connection: Double-check wp-config.php permissions (644) and ensure MySQL details are correct.
For more advanced usage, check the official docs with wp help core or visit wp-cli.org in your browser.