Skip to content

Instantly share code, notes, and snippets.

@markhowellsmead
Forked from neverything/comopser-wp-cli.md
Created April 29, 2018 09:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save markhowellsmead/4a6c95d53da0565c8e3b786939f1c6ac to your computer and use it in GitHub Desktop.
Save markhowellsmead/4a6c95d53da0565c8e3b786939f1c6ac to your computer and use it in GitHub Desktop.
Install composer and wp-cli on cyon.ch hostings with SSH access.

Cyon.ch/Hostpoint - Install composer & wp-cli

Composer

SSH into your server and stay in the home directory of the user.

Install composer using curl. Check if you have a bin directory in your user directory already, in case you do, omit the mkdir bin.

cd ~
mkdir bin
curl -sS https://getcomposer.org/installer | php -- --install-dir=bin
mv ~/bin/composer.phar ~/bin/composer
chmod u+x ~/bin/composer

If composer --version does not work then run echo "alias composer='~/bin/composer'" >> ~/.bash_profile. Then run source ~/.bash_profile or close and reopen your SSH session.

WP-CLI

Again SSH into your server, make sure you have a bin directory and type the following commands:

curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
mv wp-cli.phar ~/bin/wp
chmod u+x ~/bin/wp

If wp —-info does not work then run echo "alias wp='~/bin/wp'" >> ~/.bash_profile. Then run source ~/.bash_profile or close and reopen your SSH session.

WP-CLI Tab completion

mkdir ~/.wp-cli
cd ~/.wp-cli
curl -O https://raw.githubusercontent.com/wp-cli/wp-cli/master/utils/wp-completion.bash
echo "source ~/.wp-cli/wp-completion.bash" >> ~/.bash_profile
source ~/.bash_profile

Now you have autocompletion of the wp-cli commands using wp <TAB><TAB>.

Self updates using cron jobs

To add these via SSH run crontab -e, type shift + A to edit and :wq to save.

WP CLI:

0	8	*	*	7	~/bin/wp cli update --yes > /dev/null

Composer

0	8	*	*	7	~/bin/composer self-update --quiet > /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment