如何安装和使用WP-CLI来管理WordPress网站

news/2024/5/20 4:45:21/文章来源:https://blog.csdn.net/culi3118/article/details/108379202

Speeding up your work process should be one of your top priorities. Simply put, if you do more work in less time, then you will have more time to work on more projects, study and rest.

加快工作流程应该是您的首要任务之一。 简而言之,如果您用更少的时间做更多的工作,那么您将有更多的时间从事更多的项目,学习和休息。

WP-CLI is one of the command line tools specifically made to manage your WordPress websites through the command line. With a few simple commands, you can manage WordPress without even needing to login to your WordPress admin and navigate through the pages.

WP-CLI是专门用于通过命令行管理WordPress网站的命令行工具之一。 使用一些简单的命令,您甚至无需登录WordPress管理员并浏览页面即可管理WordPress。

WordPress WP-CLI

In this tutorial, we’re going to learn exactly what WP-CLI is, how to install it and an overview of the basic commands of this tool.

在本教程中,我们将确切学习WP-CLI是什么,如何安装它以及该工具的基本命令概述。

WP-CLI will be particularly useful if you are a WordPress developer, System Administrator or run a business built around WordPress. This command line tool will greatly help you do more in less time. For example, taking backups, updating WordPress and plugins, publishing content and querying databases can be accomplished relatively quickly.

如果您是WordPress开发人员,系统管理员或围绕WordPress建立业务,WP-CLI将特别有用。 此命令行工具将极大地帮助您在更短的时间内完成更多工作。 例如,可以相对快速地完成备份,更新WordPress和插件,发布内容和查询数据库。

WP-CLI的要求 (Requirements of WP-CLI)

To install WP-CLI, make sure you have a hosting account with SSH access. Most shared hosting providers do not give you access to SSH. Providers like DigitalOcean, Linode and AWS are ideal for this if you love to spin up your own servers.

要安装WP-CLI,请确保您拥有具有SSH访问权限的托管帐户。 大多数共享主机提供商都不允许您访问SSH。 如果您喜欢启动自己的服务器,则DigitalOcean,Linode和AWS等提供商非常适合此目的。

Other requirements are basic:

其他要求是基本的:

  1. PHP 5.3.2 or later.

    PHP 5.3.2或更高版本。
  2. WordPress 3.4 or later.

    WordPress 3.4或更高版本。
  3. UNIX like environment like Linux.

    像Linux这样的UNIX环境。

如何安装WP-CLI (How to Install WP-CLI)

第1步 (Step 1)

First connect to your server’s command line through SSH. You can install the latest version of WP-CLI using the cURL or wget command. The WP-CLI installation file is available as a phar file and the latest version can be found at:

首先通过SSH连接到服务器的命令行。 您可以使用cURL或wget命令安装最新版本的WP-CLI。 WP-CLI安装文件以phar文件形式提供,最新版本可在以下位置找到:

https://raw.github.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

https://raw.github.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

Using the cURL command, type:

使用cURL命令,键入:

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

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

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

This will download and extract the WP-CLI files to your root user directory.

这将下载WP-CLI文件并将其解压缩到您的根用户目录。

第2步 (Step 2)

Next, we will set the permissions to make it executable. Enter the following command:

接下来,我们将设置权限以使其可执行。 输入以下命令:

chmod +x wp-cli.phar

第三步 (Step 3)

Optionally, we can move wp-cli.phar to a folder and rename it to wp. This will help us use the WP-CLI commands by just typing ‘wp’ at the start of the commands.

(可选)我们可以将wp-cli.phar移至文件夹并将其重命名为wp。 通过在命令开头键入“ wp”,这将有助于我们使用WP-CLI命令。

sudo mv wp-cli.phar /usr/local/bin/wp

That’s it! Now we can jump in to use many of the WP-CLI commands.

而已! 现在我们可以跳入使用许多WP-CLI命令。

基本的WP-CLI命令 (Basic WP-CLI Commands)

To keep it simple, we’re going to overview the basic WP-CLI commands. You can explore more commands here.

为简单起见,我们将概述基本的WP-CLI命令。 您可以在此处探索更多命令 。

使用WP-CLI帮助系统 (Using the WP-CLI Help System)

WP-CLI comes with a full help system that you can access by typing “wp help”, for example:

WP-CLI带有完整的帮助系统,您可以通过键入“ wp help”来访问它,例如:

wp help cache

Will display information as:

将信息显示为:

名称 (NAME)

wp cache

描述 (DESCRIPTION)

Manage the object cache.

概要 (SYNOPSIS)

wp cache <command>

子命令 (SUBCOMMANDS)

add – Add a value to the object cache. decr – Decrement a value in the object cache. delete – Remove a value from the object cache. flush – Flush the object cache. get – Get a value from the object cache. incr – Increment a value in the object cache. replace – Replace an existing value in the object cache. set – Set a value to the object cache. type – Attempts to determine which object cache is being used.

add –向对象缓存添加一个值。 decr –减少对象缓存中的值。 delete –从对象缓存中删除一个值。 flush –刷新对象缓存。 get –从对象缓存中获取一个值。 incr –在对象缓存中增加一个值。 replace –替换对象缓存中的现有值。 set –为对象缓存设置一个值。 type –尝试确定正在使用哪个对象缓存。

例子 (EXAMPLES)

wp cache set my_key my_value my_group 300                                                                                                
wp cache get my_key my_group

You can use the help system to understand what you can do with the commands and their respective subcommands.

您可以使用帮助系统来了解如何使用命令及其相应的子命令。

使用WP-CLI安装WordPress (Installing WordPress with WP-CLI)

If you haven’t installed WordPress by using any other method on your server, then you can easily do so using WP-CLI command wp core install. Along with that command we need to pass parameters such as URL, Title, Admin Username, Password and Admin Email.

如果您尚未在服务器上使用任何其他方法来安装WordPress,则可以使用WP-CLI命令wp core install轻松地进行wp core install 。 与该命令一起,我们需要传递诸如URL,标题,管理员用户名,密码和管理员电子邮件之类的参数。

wp core install --url="your_domain"  --title="Blog Title" --admin_user="admin username" --admin_password="enter_your_password" --admin_email="enter_your_email"

使用WP-CLI安装主题 (Installing Themes with WP-CLI)

Importing and installing themes is much quicker through WP-CLI than going into WordPress admin, searching and then activating it.

通过WP-CLI导入和安装主题比进入WordPress管理,搜索然后激活它要快得多。

It connects your server directly to the WordPress theme repository and imports the theme in a matter of a few seconds. For example, to install a theme like TwentyTen, we will use the following command:

它将您的服务器直接连接到WordPress主题存储库,并在几秒钟内导入主题。 例如,要安装类似TwentyTen的主题,我们将使用以下命令:

wp theme install twentyten

Similarly, to install P2 theme, our command will become:

同样,要安装P2主题,我们的命令将变为:

wp theme install p2

To activate the themes on your WordPress website, you will need to use the following command:

要在WordPress网站上激活主题,您将需要使用以下命令:

wp theme activate p2

使用WP-CLI安装插件 (Installing Plugins with WP-CLI)

Just like the themes, plugins can also be installed right from the official repository. Installation is seamless and takes almost no time.

就像主题一样,插件也可以直接从官方存储库安装。 安装是无缝的,几乎不需要时间。

For example: wp plugin install woocommerce

例如: wp plugin install woocommerce

The above command will install the WooCommerce plugin on your website. To activate it, we will use the command:

上面的命令将在您的网站上安装WooCommerce插件。 要激活它,我们将使用以下命令:

wp plugin activate woocommerce

Similarly, to deactivate any plugin, the command becomes:

同样,要停用任何插件,命令将变为:

wp plugin deactivate woocommerce

使用WP-CLI更新WordPress核心,主题和插件 (Updating WordPress Core, Themes and Plugins with WP-CLI)

Repetitive and often time consuming task of updating the WordPress core, themes and plugins can be easily carried out through the command line.

更新WordPress核心,主题和插件的重复性任务通常很耗时,可以通过命令行轻松完成。

To update the WordPress core to the latest stable release of WordPress, the command is:

要将WordPress核心更新为WordPress的最新稳定版本,命令为:

wp core update

If you want to update to a specific version, for example you have WordPress 3.7 and want to move to WordPress 4.0 instead of WordPress 4.3, use the command:

如果要更新到特定版本,例如,您拥有WordPress 3.7,并且想要迁移到WordPress 4.0而不是WordPress 4.3,请使用以下命令:

wp core update --version=4.0

Or, if for any reason you want to revert back your WordPress site to the previous version, the command is:

或者,如果出于任何原因您想将WordPress网站恢复为以前的版本,则命令为:

wp core update --version=3.9 --force

To update plugins, you can either define one plugin to update or better still, update all the plugins in one go.

要更新插件,您可以定义一个要更新的插件,或者更好的方法是一次性更新所有插件。

wp plugin update woocommerce
wp plugin update --all

A similar method applies to the themes. You can update WordPress themes through WP-CLI with following command

类似的方法适用于主题。 您可以使用以下命令通过WP-CLI更新WordPress主题

wp theme update twentyten
wp theme update --all

结论 (Conclusion)

WP-CLI is indeed a powerful tool that can be used to manage your WordPress sites through the command line. There are also many more commands to manage your database, take backups, manage posts, comments and WordPress multisite It definitely speeds up your tasks, and makes it really easy to manage the sites. Luckily, there are hosting providers that provide WP-CLI by default on their WordPress installations (you can find a maintained list here).

WP-CLI确实是一个功能强大的工具,可用于通过命令行管理WordPress网站。 还有许多其他命令可用于管理数据库,进行备份,管理帖子,评论和WordPress多站点。这无疑加快了您的工作速度,并使其真正易于管理。 幸运的是,有默认情况下在其WordPress安装中提供WP-CLI的托管服务提供商( 您可以在此处找到维护的列表 )。

翻译自: https://www.sitepoint.com/wp-cli/

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.luyixian.cn/news_show_785170.aspx

如若内容造成侵权/违法违规/事实不符,请联系dt猫网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

wordpress快速建站_快速提示:使用WordPress联络表7增强选择加入

wordpress快速建站You might have heard the saying, “the money is in the list”. Your email list, to be exact. Email marketing is widely considered to be the most powerful form of marketing today, and there are plenty of stats to back it up. 您可能已经听说过…

php网站功能块学习_学习PHP 7,了解新功能等

php网站功能块学习PHP 7, the next version of the world’s most popular programming language, has been released. We’d love to shoot fireworks and get drunk with our newfound power (seriously, the language is in the true big leagues now, functionality and pe…

wordpress网站迁移_如何将您的WordPress网站迁移到新的托管服务提供商

wordpress网站迁移This article is part of a series created in partnership with SiteGround. Thank you for supporting the partners who make SitePoint possible. 本文是与SiteGround合作创建的系列文章的一部分。 感谢您支持使SitePoint成为可能的合作伙伴。 We’ve be…

wordpress 静态化_地理定位WordPress内容以个性化您的网站

wordpress 静态化So what does that phrase mean, “Geo-Targeting WordPress Content”? First, let’s back up and look at an example of personalization. 那么&#xff0c;这句话是什么意思&#xff0c;“以地理定位的WordPress内容”&#xff1f; 首先&#xff0c;让我…

next主题seo优化_SEO可见性的5个最佳WordPress主题

next主题seo优化This article is part of a series created in partnership with SiteGround. Thank you for supporting the partners who make SitePoint possible. 本文是与SiteGround合作创建的系列文章的一部分。 感谢您支持使SitePoint成为可能的合作伙伴。 Theme selec…

cloudflare_使用Cloudflare使您的网站更快,更安全

cloudflareCloudflare is an industry leader in the content-delivery space, reducing load and speeding up millions of websites. Cloudflare是内容交付领域的行业领导者&#xff0c;可减轻负载并加快数百万个网站的速度。 What is peculiar about this provider is that…

六个最受欢迎的 CMS 建站系统,不容错过|Gitee项目推荐

CMS 是 Content Management System 的缩写&#xff0c;意为"内容管理系统"。 内容管理系统是企业信息化建设和电子政务的新宠&#xff0c;也是一个相对较新的市场。对于内容管理&#xff0c;业界还没有一个统一的定义&#xff0c;不同的机构有不同的理解。CMS 在各行…

html 相对路径 网站根目录,html中的绝对路径URL和相对路径URL及子目录、父目录、根目录...

绝对URL用于表示Internet中特定文件所需要的全部内容&#xff0c;Internet中的每一个文件都有一个唯一的URL&#xff0c;这就是在网页中搜索时需要输入到地址栏的连接。例如&#xff0c;要进入百度一下的网页&#xff0c;则在网页地址栏中输入&#xff1a;即可。一旦进入到某个…

php网站整合ck播放器,网页视频播放器-ckplayer 整合到wordpress

在这里我将教大家怎样将这款播放器整合到wordpress中来&#xff0c;并教大家怎么将优酷视频用到这款播放器上面!第一步&#xff1a;我们要下载一个播放器文件第二步&#xff1a;将下载文件解压出来&#xff0c;打开里面player文件夹下ckplayer.txt文本文档&#xff0c;将里面的…

【最新】某素材网站上的虎年高质量海报素材合集,附带源文件和预览图

原格式PSD提供给大家同时提供jpg预览图&#xff0c;马上过年了&#xff0c;这套素材用的上&#xff0c;红色喜庆 醉了&#xff0c;本来想整理的上传的&#xff0c;但是发现有水印&#xff0c;现在水印已经全部去除&#xff0c;放心食用&#xff0c;每个图都比较大&#xff0c;一…

使用SSM重新开发计科院网站

一、游览 在游览器地址栏输入&#xff1a;http://localhost:8080/index&#xff0c;即访问计科院首页&#xff0c;由于前期对数据库以及JavaBean的设计考虑不够充分&#xff0c;导致后期的代码臃肿&#xff0c;所以项目启动时对首页进行数据的填充难以实现&#xff0c;必须输入…

airpods固件更新方法_AirPods Pro 固件更新,空间音频来了丨 网站证书更新

09/15 网站证书更新 证书已上传,网站福利应用正在更新中…… 福利区已修复完毕,不知道能活多久! 证书已经上传(回复 证书 获取证书下载链接),证书使用教程查看历史文章 【福利升级】iOS苹果端免越狱 手机端签名神器教程来了! 删掉之前的APP再重新下载即可! 证书很不稳…

java程序员语录_「java程序员面试题」2018java程序员面试题整理 - seo实验室

java程序员面试题1.PathVariable注解和requestParam注解的区别。RequestParam注解是获取静态URL传入的参数PathVariable是获取请求路径中的变量作为参数/需要和RequestMAPPing("item/{itemId}") 配合使用2.Param注解和RequestParam注解的区别。Parm 指定request中必…

java webshell_网站漏洞测试 关于webshell木马后门检测

前段时间我们SINE安全收到客户的渗透测试服务委托,在这之前,客户网站受到攻击,数据被篡改,要求我们对网站进行全面的渗透测试,包括漏洞的检测与测试,逻辑漏洞.垂直水平越权漏洞,文件上传漏洞.等等服务项目,在进行安全测试之前,我们对客户的网站大体的了解了一下,整个平台网站,包…

java摄影网站源码_基于jsp的摄影网站-JavaEE实现摄影网站 - java项目源码

基于jspservletpojomysql实现一个javaee/javaweb的摄影网站, 该项目可用各类java课程设计大作业中, 摄影网站的系统架构分为前后台两部分, 最终实现在线上进行摄影网站各项功能,实现了诸如用户管理, 登录注册, 权限管理等功能, 并实现对各类摄影网站相关的实体进行管理。该摄影…

scrapy入门实战-爬取代理网站

相关视频&#xff1a; Python之scrapy入门_哔哩哔哩_bilibili 转&#xff1a;scrapy入门实战-爬取代理网站 - JayMu - 博客园 入门scrapy。 学习了有这几点 1.如何使用scrapy框架对网站进行爬虫&#xff1b; 2.如何对网页源代码使用xpath进行解析&#xff1b; 3.如何书写…

逆向路上强大的在线网站

在线 arm汇编 转 hex进制 优秀网站推荐&#xff1a; https://armconverter.com/ 算法之美编码算法 &#xff1a; https://gchq.github.io/CyberChef/ 不想写代码可以用该网站生成&#xff1a;&#xff08;圈内人开发的&#xff09; https://www.spidertools.cn/#/formatHeader…

总裁导航v2.5.1修复版秒收录网站模板源码指定定时收录导航站

总裁导航系统&#xff0c;一款多功能的php导航系统&#xff0c;不仅仅支持自助申请收录&#xff0c;并且还支持自助购买广告 还有很多功能&#xff01; 1.新增加前台用户自助购买广告功能 2.新增加自动审核功能 3.自动定时提交百度收录&#xff01; 环境要求&#xff1a;PHP7.…

主流影视网站8合一H5视频源码自动更新数据

更新说明&#xff1a; 1.升级全新数据源&#xff0c;速度更快&#xff0c;资源更全 2.取消系统缓存机制&#xff0c;修正因大量缓存导致服务器硬盘填满bug 3.源码精简&#xff0c;体积更小&#xff0c;更易维护或二次开发 4.修复使用百度统计等统计代码时无法正常统计bug 已测…

宁波医院挂号网上预约,为什么跳出本网站部允许代理服务器,当心!预约挂号后爽约会怎样?后果有点重…...

原标题&#xff1a;当心&#xff01;预约挂号后爽约会怎样&#xff1f;后果有点重…日前&#xff0c;为加强预约挂号管理&#xff0c;提高号源利用率&#xff0c;规范就医行为&#xff0c;市卫生计生委组织编写了《宁波市预约挂号退号与爽约管理规范》。预约挂号后爽约会怎样&a…