So when I tried to run WP-CLI on namecheap.com with
php wp-cli.phar --info
absolutely nothing happened. It just went to the next line in the terminal, no hints nothing.
Some background, I bought some incredibly cheap webhosting from namecheap.com today. Real cheap! Like €8 for the first year. You can bring along your own domain address as the main domain, they are pretty flexible. I got mine from 1and1.com who are doing a crazy cheap €1 deal for .com’s at the minute. Totally check it out.
Next, if you are me, you have to get in touch with support to enable ssh access. The ssh port is obfuscated (not 22), check the literature. Next I checked for wp-cli by trying to run wp, nowt. Incidentally wp-cli comes installed by default in Hostgator shared hosting, but you have to set up the bash completion yourself, see further below.
Installing WP-CLI on NameCheap.com
So back to the issue at hand trying to run wp-cli yields no output whatsoever. As it turns out .phar files are not being whitelisted in php.ini. A quick solution to this is to add a line to our aliases in .bashrc
alias php='php -d suhosin.executor.include.whitelist=phar'
I put my wp-cli.phar file, which I got using:
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
, into some folder. Remembered but out of the way. Then I added another alias for ‘wp’. Something like:
alias php='php -d suhosin.executor.include.whitelist=phar' alias wp='php ~/<important-remembered-folder>/wp-cli.phar'
Make sure the ‘wp’ alias is after the ‘php’ alias or it will not work. You can test it immediately by running:
prompt$ source .bashrc (to load our new aliases) prompt$ wp --info (and you should get something like this:) PHP binary: /usr/selector/php-cli PHP version: 5.4.35 php.ini used: /usr/local/lib/php.ini WP-CLI root dir: phar://wp-cli.phar WP-CLI global config: WP-CLI project config: WP-CLI version: 0.17.1 prompt$
Coolio, you are set. Now the bash completions, which are mega handy.
Setting up WP-CLI bash Tab Completions
So download the file wp-completions.bash from github. I got mine from here
curl -O https://raw.githubusercontent.com/wp-cli/wp-cli/master/utils/wp-completion.bash
Put this file in that important remembered folder again. Then you need to add the following line to .bash_profile after where it has loaded .bashrc -if that is applicable to your version of .bash_profile. It will look something like this:
# .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # Bash completions for wp-cli. (You can not use the ~/ shortcut for $HOME) # *** The next line is what you should be paying attention to! *** source /home/<your-user-name>/<important-remembered-folder>/wp-completion.bash # User specific environment and startup programs PATH=$PATH:$HOME/bin export PATH
That’s it. Log out and in again or run ‘login’ and you will have tab completions, which are a joy to use after faffing around blind for a good while. I hope this helps.
Originally posted on Ros’ Rants