{"id":8886,"date":"2020-04-14T09:41:23","date_gmt":"2020-04-14T06:41:23","guid":{"rendered":"https:\/\/vipestudio.com\/?p=8886"},"modified":"2020-04-14T13:44:35","modified_gmt":"2020-04-14T10:44:35","slug":"wordpress-and-ssh-introduction-to-wp-cli","status":"publish","type":"post","link":"https:\/\/vipestudio.com\/en\/wordpress-and-ssh-introduction-to-wp-cli\/","title":{"rendered":"WordPress and SSH: Introduction to WP-CLI"},"content":{"rendered":"<p style=\"text-align: left;\">Like we mentioned in Part 1 of this \u201cSSH and WordPress\u201d series, WP-CLI is something that lets you skip the login and navigation and execute text commands for WordPress via a terminal environment. Use WP-CLI, and anything from backups to updates for plugins and queries can all happen in no time.<\/p>\n<h2 style=\"text-align: left;\">What you need for WP-CLI<\/h2>\n<p style=\"text-align: left;\">Some web hosts have WP-CLI by default, in which case, skip right ahead to the next section after \u2018WP-CLI Installation\u2019. For setting WP-CLI up yourself, you\u2019ll need to meet a few requirements. Besides the SSH access we set up in part 1, you\u2019ll need PHP (at least 5.3.2), WordPress 3.4 or newer, and a terminal environment of the sort we\u2019ve already set up.<\/p>\n<h2 style=\"text-align: left;\">WP-CLI Installation<\/h2>\n<p style=\"text-align: left;\">Start by logging in to your server over SSH. You can then use the cURL command or wget command to download WP-CLI. The up-to-date setup (as a .phar file) can be found on the <a href=\"https:\/\/raw.githubusercontent.com\/wp-cli\/builds\/gh-pages\/phar\/wp-cli.phar\" target=\"_blank\" rel=\"noopener noreferrer\">GitHub page for WP-CLI<\/a>. So you can type:<\/p>\n<p style=\"text-align: left;\"><code>cURL \u2013O https:\/\/raw.githubusercontent.com\/wp-cli\/builds\/gh-pages\/phar\/wp-cli.phar<\/code><\/p>\n<p style=\"text-align: left;\">WP-CLI will now be installed to the root directory.<\/p>\n<p style=\"text-align: left;\">For the next part, we need to set permissions so we can execute WP-CLI, for which we enter:<\/p>\n<p style=\"text-align: left;\"><code>chmod +x wp-cli.phar<\/code><\/p>\n<p style=\"text-align: left;\">In addition, you may also move the downloaded .phar file to a folder and name it just \u2018wp\u2019. This way, prefixing \u2018wp\u2019 will make any WP-CLI command work. Type:<\/p>\n<p style=\"text-align: left;\"><code>sudo mv wp-cli.phar \/usr\/local\/bin\/wp<\/code><\/p>\n<p style=\"text-align: left;\">Now we\u2019re good to go.<\/p>\n<h2 style=\"text-align: left;\">Basic WP-CLI Commands<\/h2>\n<p style=\"text-align: left;\">We can now execute the commands. The most basic command \u2018wp help\u2019 is something you can use to access the full WP-CLI help database to learn what each command does, and even what role the subcommands play.<\/p>\n<p style=\"text-align: left;\">In order to execute the help command, you need to move to the directory that you installed WP-CLI to. To do this you may use \u2018ls\u2019 and reveal the current directory status. WP-CLI also allows you to install themes using the following:<\/p>\n<p style=\"text-align: left;\"><code>wp theme install name_of_theme<\/code><\/p>\n<p style=\"text-align: left;\">Then we can activate the theme by:<\/p>\n<p style=\"text-align: left;\"><code>wp theme activate name_of_theme<\/code><\/p>\n<p style=\"text-align: left;\">The themes are directly imported from the Theme Repository.<\/p>\n<p style=\"text-align: left;\">Commands can be used to install plugins as well from the official repository with the following command:<\/p>\n<p style=\"text-align: left;\"><code>wp plugin install name_of_plugin<\/code><\/p>\n<p style=\"text-align: left;\">And activation will be:<\/p>\n<p style=\"text-align: left;\"><code>wp plugin activate name_of_plugin<\/code><\/p>\n<p style=\"text-align: left;\">To disable the plugins, on the other hand, it\u2019s as simple as typing<\/p>\n<p style=\"text-align: left;\"><code>wp plugin deactivate name_of_plugin<\/code><\/p>\n<p style=\"text-align: left;\">You can type<\/p>\n<p style=\"text-align: left;\"><code>wp plugin list<\/code><\/p>\n<p style=\"text-align: left;\">to show all the available plugins. To update all your eligible plugins you can execute<\/p>\n<p style=\"text-align: left;\"><code>wp plugin update<\/code><\/p>\n<p style=\"text-align: left;\">If you want to get some more fine-grained control, type<\/p>\n<p style=\"text-align: left;\"><code>wp plugin update \u2013-all --dry-run<\/code><\/p>\n<p style=\"text-align: left;\">to give you the list of plugins that would be updated by the first command.<\/p>\n<p style=\"text-align: left;\">In fact, even WordPress itself can be installed if you type and execute<\/p>\n<p style=\"text-align: left;\"><code>wp core install<\/code><\/p>\n<p style=\"text-align: left;\">Of course, you need to complete the command with other attributes like URL, username, password and email.<\/p>\n<p style=\"text-align: left;\">To learn more about the WP-CLI commands, you can refer to the official <a href=\"http:\/\/wp-cli.org\/commands\" target=\"_blank\" rel=\"noopener noreferrer\">WP-CLI manual<\/a> at their website.<\/p>\n<p style=\"text-align: left;\">You are now ready to deploy all the advanced and power-user tools and control your WordPress website and environment better. Some hosting solutions will even let you use Git, npm and other tools. As you use SSH and learn more about WP-CLI, you\u2019ll learn more and more things you can achieve with SSH and the command line, and in no time, you\u2019ll be a natural at doing things the smarter way!<\/p>\n<p style=\"text-align: left;\">With the power of SSH in your hands, your WordPress experience is faster, and you can say goodbye to the days of clicking through page after page to perform basic WordPress functions. As promised in part 1, you are now indeed a WordPress ninja with SSH!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Like we mentioned in Part 1 of this \u201cSSH and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":8914,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[116],"tags":[189,185,184,187,186],"class_list":["post-8886","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-freestyle","tag-bash","tag-linux","tag-ssh","tag-terminal","tag-wp-cli"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/vipestudio.com\/en\/wp-json\/wp\/v2\/posts\/8886","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vipestudio.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vipestudio.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vipestudio.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vipestudio.com\/en\/wp-json\/wp\/v2\/comments?post=8886"}],"version-history":[{"count":0,"href":"https:\/\/vipestudio.com\/en\/wp-json\/wp\/v2\/posts\/8886\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/vipestudio.com\/en\/wp-json\/wp\/v2\/media\/8914"}],"wp:attachment":[{"href":"https:\/\/vipestudio.com\/en\/wp-json\/wp\/v2\/media?parent=8886"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vipestudio.com\/en\/wp-json\/wp\/v2\/categories?post=8886"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vipestudio.com\/en\/wp-json\/wp\/v2\/tags?post=8886"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}