This article covers the steps for installing WP-CLI on a cPanel server, including enabling autocomplete for quicker and more effective command usage.
Before you begin, ensure the following:
- A server with cPanel installed.
- SSH access to the server (as a user with sudo/root privileges).
Let us follow the installation Steps:
- Start by downloading WP-CLI:
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
- Change file permissions to enable execution:
chmod +x wp-cli.phar
- Transfer WP-CLI to the Global executables folder:
mv wp-cli.phar /usr/local/bin/wp
- Fetch the WP-CLI Autocomplete script:
wget https://raw.githubusercontent.com/wp-cli/wp-cli/master/utils/wp-completion.bash
- Deploy the Autocomplete Script to the Bash Completion Path:
mv wp-completion.bash /etc/bash_completion.d/wp-completion.bash
- Include the Bash Completion Directory in Jailshell Mounts:
echo “/etc/bash_completion.d” >> /var/cpanel/jailshell-additional-mounts
- Run the Script to Enable Autocomplete:
echo “source /etc/bash_completion.d/wp-completion.bash” >> /etc/profile.d/wpcli-autocomplete.sh
- Test the WP-CLI Autocomplete:
source /etc/profile.d/wpcli-autocomplete.sh
In such a manner, you can set up WP-CLI and enable Autocomplete on a cPanel Server. For such informative articles, do visit our knowledge base section regularly.
Looking to deploy WordPress using WP-CLI on AlmaLinux? Check out How to install WordPress through WP-CLI on AlmaLinux