WP-CLI 安装使用图文教程

WP-CLI is the command-line interface for WordPress. You can update plugins, configure multisite installations and much more, without using a web browser.

Installing

Downloading the Phar file is our recommended installation method for most users. Should you need, see also our documentation on alternative installation methods (ComposerHomebrewDocker).

Before installing WP-CLI, please make sure your environment meets the minimum requirements:

  • UNIX-like environment (OS X, Linux, FreeBSD, Cygwin); limited support in Windows environment
  • PHP 5.6 or later
  • WordPress 3.7 or later. Versions older than the latest WordPress release may have degraded functionality

Once you’ve verified requirements, download the wp-cli.phar file using wget or curl:

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

Next, check the Phar file to verify that it’s working:

php wp-cli.phar --info

To use WP-CLI from the command line by typing wp, 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

If WP-CLI was installed successfully, you should see something like this when you run wp --info:

$ wp --info OS:     Linux 5.10.60.1-microsoft-standard-WSL2 #1 SMP Wed Aug 25 23:20:18 UTC 2021 x86_64 Shell:  /usr/bin/zsh PHP binary:     /usr/bin/php8.1 PHP version:    8.1.0 php.ini used:   /etc/php/8.1/cli/php.ini MySQL binary:   /usr/bin/mysql MySQL version:  mysql  Ver 8.0.27-0ubuntu0.20.04.1 for Linux on x86_64 ((Ubuntu)) SQL modes: WP-CLI root dir:        /home/wp-cli/ WP-CLI vendor dir:      /home/wp-cli/vendor WP_CLI phar path: WP-CLI packages dir:    /home/wp-cli/.wp-cli/packages/ WP-CLI global config: WP-CLI project config:  /home/wp-cli/wp-cli.yml WP-CLI version: 2.6.0

Usage

WordPress插件WP-JPOST使用WP_CLI命令行进行任务

cd /www/wwwroot/uziwp.com/ ; wp jpost 1

进入到wordpress所在的目录之后,运行命令, wp jpost 任务ID

腾讯云限时秒杀【点击购买】

Vultr$3.5日本节点,512M内存/500G流量/1G带宽,电信联通优化,延迟低,速度快【点击购买】!

阿里云香港、新加坡VPS/1核/1G/25G SSD/1T流量/30M带宽/年付¥288【点击购买】


Posted

in

by