Skip to content

Instantly share code, notes, and snippets.

@kauhat
Last active January 11, 2020 20:26
Show Gist options
  • Save kauhat/8e8d79a8197558b73298 to your computer and use it in GitHub Desktop.
Save kauhat/8e8d79a8197558b73298 to your computer and use it in GitHub Desktop.
WP-CLI setup on Tsohost and Heart Internet shared servers
# Add ~/bin directory to path if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$PATH:$HOME/bin"
fi
# Set up alias for WP CLI
alias wp="php-7.2 $HOME/bin/wp-cli.phar"

Install guide

  1. Run the following commands via SSH.
mkdir -p ~/bin \
  && curl -o ~/bin/wp-cli.phar https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar \
  && curl -o ~/bin/wp-completion.bash https://raw.githubusercontent.com/wp-cli/wp-cli/master/utils/wp-completion.bash \
  && curl https://gist.githubusercontent.com/kauhat/8e8d79a8197558b73298/raw/.bashrc >> ~/.bashrc \
  && echo "source ~/bin/wp-completion.bash" >> ~/.bash_profile; \
source ~/.bash_profile && source ~/.bashrc;
  1. Tweak your .bashrc file if necessary. Don't forget to reload it by running source ~/.bashrc.

Notes

The provided .bashrc file adds the ~/bin directory to the path so that you can use programs installed there easily from the terminal. You can check the version of php being by using which php. If it doesn't exist or is the wrong version, you can modify the alias line in your .bashrc.

Backing up a WordPress installation

tar cvzf backup.tar.gz public_html
wp db export backup.sql --path=public_html

Replace public_html with wherever the site lives.

@kauhat
Copy link
Author

kauhat commented Mar 17, 2015

Install WP-CLI to your ~/bin directory. Edit the last line if you've got it installed elsewhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment