WP-CLI not working on namecheap.com [SOLVED]

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.

Background

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

2 thoughts on “WP-CLI not working on namecheap.com [SOLVED]

  1. OK, minus ten points to namecheap, but also “you get what you pay for”. I couldn’t install wordpress and was getting internal server 500 errors when I tried to access it. Finally tracked it down to the fact that the webserver was not able to serve php files! Html files were fine. I actually ended up calling support which was pretty unusual for me, he took ages but fixed it. When I asked what was wrong he said I had the wrong file permissions on my php files (???). Not really up to me to change the file permissions. Ordinarily an instance of apache is run under your own username on shared hosting or some other solution that is hidden from the user.

    Anyhow, pretty half-arsed installation on their part, but the support was good. No problems like their can be sometimes, with agents insisting that black is white.

  2. Nice. Thanks for sharing this. The wp-cli install worked. Not sure how the tab completion works just yet but I imagine it worked too.

Comments are closed.