无脑安装代码:

cd ~
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
php wp-cli.phar --info
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
wp --info

The recommended way to install WP-CLI is by downloading the Phar build (archives similar to Java JAR files, see this article for more detail), marking it executable, and placing it on your PATH.

First, download wp-cli.phar using

wget

or

curl

. For example:


curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

Then, check if it works:


php wp-cli.phar --info

To be able to type just

wp

, instead of

php wp-cli.phar

, you need to make the file executable and move it to somewhere in your PATH. For example:


chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp

Now try running

wp --info

. If WP-CLI is installed successfully, you’ll see output like this:


OS:  Linux 4.10.0-42-generic #46~16.04.1-Ubuntu SMP Mon Dec 4 15:57:59 UTC 2017 x86_64
Shell:   /usr/bin/zsh
PHP binary:    /usr/bin/php
PHP version:     7.1.12-1+ubuntu16.04.1+deb.sury.org+1
php.ini used:   /etc/php/7.1/cli/php.ini
WP-CLI root dir:        /home/wp-cli/.wp-cli
WP-CLI packages dir:    /home/wp-cli/.wp-cli/packages/
WP-CLI global config:   /home/wp-cli/.wp-cli/config.yml
WP-CLI project config:
WP-CLI version: 1.5.0

Voila! You’re now an official WP-CLI user.

Wondering what to do next? Check out the quick start guide for a short introduction and some example usage.

Oh My Zsh Oh My Zsh

If you’re using the Oh My Zsh framework, you can enable the built-in wp-cli plugin, by adding it to the

plugins=(
  git zsh-autosuggestions wp-cli
)

line in your

vi ~/.zshrc

file.

Note: the Oh My Zsh plugin comes with the bash completion script included, so it’s unnecessary to have both.

To have this change take effect in your currently active shell, run

source ~/.zshrc

afterwards.

参考:

Installing

分类: 未分类

发表评论

电子邮件地址不会被公开。 必填项已用*标注