{"id":229,"date":"2015-04-12T04:13:18","date_gmt":"2015-04-12T04:13:18","guid":{"rendered":"https:\/\/www.fastcomet.com\/blog\/?p=229"},"modified":"2022-06-10T07:53:13","modified_gmt":"2022-06-10T07:53:13","slug":"wp-cli-on-shared-hosting","status":"publish","type":"post","link":"https:\/\/www.fastcomet.com\/blog\/wp-cli-on-shared-hosting","title":{"rendered":"WP-CLI Available on Shared Hosting Environment"},"content":{"rendered":"\n<p class=\"has-drop-cap\">Everyone knows that WordPress is the most used Open Source application these days and there are quite a lot of useful tools released for improving the client experience with that application. Recently we have found a tool called &#8220;<a href=\"https:\/\/wp-cli.org\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">WP-CLI<\/a>&#8221; which will dramatically improve the interaction with WordPress for those geeky users that are familiar and quite comfortable using the command line (ssh) of their WordPress Hosting Accounts.<\/p>\n\n\n\n<!--more-->\n\n\n\n<h2 class=\"wp-block-heading\">What is CLI?<\/h2>\n\n\n\n<p>As you might have heard CLI stands for <strong>Command Line Interface<\/strong> and it is used to execute shell commands towards the operating system of a computer. No matter if you would like to send the commands to your local computer or the web server hosting your website you will have to use a Command Line Interface in order to interact with different services.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How actually WP-CLI works?<\/h3>\n\n\n\n<p>WP-CLI, executed in the installation directory of your WordPress website will easily handle most of the common tasks you usually perform over the WordPress web interface. For example:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li style=\"text-align: justify;\">Managing the WordPress caches<\/li><li style=\"text-align: justify;\">Managing the WordPress cron events and schedules<\/li><li style=\"text-align: justify;\">Managing the WordPress media attachments<\/li><li style=\"text-align: justify;\">Installing WordPress<\/li><li style=\"text-align: justify;\">Installing Plugins<\/li><li style=\"text-align: justify;\">Installing Themes<\/li><li style=\"text-align: justify;\">Updating WordPress<\/li><\/ol>\n\n\n\n<p>and much more. You can see the full list of useful commands at the official <a href=\"https:\/\/developer.wordpress.org\/cli\/commands\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">WP-CLI Commands<\/a> page. By executing each command with its parameters you will be able to easily and most importantly securely fully manage your WordPress website.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Using WP-CLI<\/h2>\n\n\n\n<p>With the recent improvements of our <a href=\"https:\/\/my.fastcomet.com\/order\/ssdcloud\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">Shared Hosting<\/a> environment you are able to use quite a lot of different features and the one we are reviewing in this post can be used with a simple command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ wp command parameters<\/code><\/pre>\n\n\n\n<p>where &#8220;<em>command<\/em>&#8221; should be replaced with one of the <a href=\"https:\/\/developer.wordpress.org\/cli\/commands\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">supported commands<\/a> and &#8220;<em>parameters<\/em>&#8221; with any of the parameters required by the used command.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Examples<\/h2>\n\n\n\n<p>Let&#8217;s review a few examples of how WP-CLI behave on our WordPress Hosting package.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Installing WordPress<\/h3>\n\n\n\n<p>WordPress installation over the command line might be quite handy if you do not have access to your domain name:<\/p>\n\n\n\n<ul><li>Create an empty directory and access it: <br><pre>$ mkdir wp-test &amp;&amp; cd wp-test<\/pre><\/li><li>Download WordPress and prepare it for installation:<br><pre>$ wp core download Downloading WordPress 4.1.1 (en_US)...<br>Using cached file '\/home\/s1intfcomet\/.wp-cli\/cache\/core\/en_US-4.1.1.tar.gz'...<br> Success: WordPress downloaded.<\/pre><\/li><li>Creating the database &#8211; you should be able to create a cPanel database following our <a rel=\"noreferrer noopener\" href=\"https:\/\/www.fastcomet.com\/tutorials\/cpanel\/create-database\" target=\"_blank\">cPanel Database<\/a> tutorial;<\/li><li>Creating configs:<br><pre>$ wp core config<br> --dbname=database_name<br> --dbuser=database_username<br> --dbpass=Database_password<br> --locale=en_EN<br> Success: Generated wp-config.php file.<\/pre><\/li><li>Running the installation command:<br><pre>$ wp core install<br> --url=\"s1int.fcomet.com\/wp-test\"<br> --title=\"Your Blog Title\"<br> --admin_user=\"admin\"<br> --admin_password=\"pass123\"<br> --admin_email=\"admin@fcomet.com\"<br> Success: WordPress installed successfully<\/pre><\/li><li>The process is a bit extended due to the generation of the configuration  file, however, you will end up with an easy and secure WordPress  installation.<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Installing Themes<\/h3>\n\n\n\n<p>The theme installation process is relatively simple and it involves the following actions:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Listing the currently installed themes<\/li><\/ol>\n\n\n\n<pre class=\"wp-block-preformatted\">$ <strong>wp theme list<\/strong>\n+----------------+----------+--------+---------+\n| name | status | update | version |\n+----------------+----------+--------+---------+\n| twentyfifteen | active | none | 1.0 |\n| twentyfourteen | inactive | none | 1.3 |\n| twentythirteen | inactive | none | 1.4 |\n+----------------+----------+--------+---------+<\/pre>\n\n\n\n<ol class=\"wp-block-list\"><li>Searching for themes &#8211; the search is as the usual WordPress themes search but quicker.<\/li><\/ol>\n\n\n\n<pre class=\"wp-block-preformatted\">$ <strong>wp theme search medical<\/strong>\nSuccess: Showing 4 of 4 themes.\n+----------------+----------------+--------+\n| name | slug | rating |\n+----------------+----------------+--------+\n| Medical | medical | 50 |\n| Medical Center | medical-center | 0 |\n| Medica Lite | medica-lite | 100 |\n| Creare Site | creare-site | 100 |\n+----------------+----------------+--------+<\/pre>\n\n\n\n<ol class=\"wp-block-list\"><li>Installing theme &#8211; in order to install the selected theme, you will need the theme &#8220;<em>slug<\/em>&#8221; from the searching results.<\/li><\/ol>\n\n\n\n<pre class=\"wp-block-preformatted\">$ <strong>wp theme install medical-center<\/strong>\nInstalling Medical Center (1.0.5)\nDownloading install package from https:\/\/downloads.wordpress.org\/theme\/medical-center.1.0.5.zip...\nUnpacking the package...\nInstalling the theme...\nTheme installed successfully.<\/pre>\n\n\n\n<ol class=\"wp-block-list\"><li>Activating theme &#8211; Again a theme should be activated using it&#8217;s &#8220;<em>slug<\/em>&#8220;<\/li><\/ol>\n\n\n\n<pre class=\"wp-block-preformatted\">$<strong> wp theme activate medical-center<\/strong>\nSuccess: Switched to 'Medical Center' theme.<\/pre>\n\n\n\n<p>In order to activate a different theme, simply use the theme slug from the list of installed themes.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Installing Plugins<\/h2>\n\n\n\n<p>The plugin installation process is the same as the Theme installation process but instead searching for the theme&#8217;s name you will need to search for the plugin&#8217;s name:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>$ wp plugin search clef\n<\/strong>Success: Showing 7 of 7 plugins.\n+--------------------------------+------------------------+--------+\n| name | slug | rating |\n+--------------------------------+------------------------+--------+\n| Clef Two-Factor Authentication | wpclef | 98 |\n| BruteProtect | bruteprotect | 96 |\n| Neeed | neeed | 0 |\n| VOD Infomaniak | vod-infomaniak | 0 |\n| Full UTF-8 | full-utf-8 | 100 |\n| Canalblog Importer | canalblog-importer | 0 |\n| Agent virtuel ASKOM | agent-virtuel-by-askom | 0 |\n+--------------------------------+------------------------+--------+<\/pre>\n\n\n\n<p>Once you have found the plugin you would like installed, simply use it&#8217;s slug again in order to get it installed and again it&#8217;s slug to get it activated:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>$ wp plugin install wpclef\n<\/strong>Installing Clef Two-Factor Authentication (2.2.9.1)\nDownloading install package from https:\/\/downloads.wordpress.org\/plugin\/wpclef.2.2.9.1.zip...\nUnpacking the package...\nInstalling the plugin...\nPlugin installed successfully.\n$ wp plugin activate wpclef\nSuccess: Plugin 'wpclef' activated.<\/pre>\n\n\n\n<p>Deactivating a plugin is also a piece of cake and in order to do so, you will need to only change &#8220;activate&#8221; with &#8220;deactivate&#8221; in the above plugin activation command.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Writing Posts<\/h2>\n\n\n\n<p>WP-CLI allows also the writing of posts directly via the command line. You do not have the text editor, however, it serves well if you would like to have a quick post written.<\/p>\n\n\n\n<p>You will need to create a .txt file with the content of the post you would like to be displayed. Let&#8217;s call it wp-cli.txt. Once you are ready you will need to upload the file on your web hosting account and to execute the following command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ wp post create .\/wp-cli.txt --post_title='wp-cli'\nSuccess: Created post 3.<\/pre>\n\n\n\n<p>Every other operation you perform on your posts will require for you to provide a post ID. This can be obtained by listing all the posts:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>$ wp post list<\/strong>\n+----+--------------+-------------+---------------------+-------------+\n| ID | post_title | post_name | post_date | post_status |\n+----+--------------+-------------+---------------------+-------------+\n| 6 | wp-cli | wp-cli | 2015-04-11 10:52:23 | publish |\n| 1 | Hello world! | hello-world | 2015-04-11 09:50:26 | publish |\n+----+--------------+-------------+---------------------+-------------+<\/pre>\n\n\n\n<p>Now that your post is added, you will need to publish it of course if you would like to. Keep in mind that you will need the post ID.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ <strong>wp post update 3 --post_status=publish<\/strong>\nSuccess: Updated post 3.<\/pre>\n\n\n\n<p>Respectively to delete a post you will also need its ID:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$<strong> wp post delete 3 --force<\/strong>\nSuccess: Deleted post 3.<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>WP-CLI happens to be quite handy as it does not depend on the loading speed of your website due to the fact that the queries to the database all made locally on your web hosting account with us. This is indeed time sparing for the administrators and the developers of WordPress websites. From this point on the feature will inhabit our Shared Hosting environment and all our Shared Hosting users will be able to use it. We will update and maintain it in the future as it is one of the most secure ways of managing your WordPress instances.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Everyone knows that WordPress is the most used Open Source application these days and there are quite a lot of useful tools released for improving the client experience with that application. Recently we have found a tool called &#8220;WP-CLI&#8221; which will dramatically improve the interaction with WordPress for those geeky users that are familiar and [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":591,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4726,256],"tags":[108,61],"class_list":["post-229","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-service-updates","category-wordpress","tag-cli","tag-shared-hosting"],"featured_image_src":"https:\/\/www.fastcomet.com\/blog\/wp-content\/uploads\/2015\/04\/wp-cli.jpg","author_info":{"display_name":"Christopher","author_link":"https:\/\/www.fastcomet.com\/blog\/author\/christopher"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>WP-CLI Available on Shared Hosting Environment | FastComet<\/title>\n<meta name=\"description\" content=\"What is WP-CLI? What is WP-CLI used for? \u261b Learn how to use the set of command-line tools for managing your WordPress installations.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.fastcomet.com\/blog\/wp-cli-on-shared-hosting\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"WP-CLI Available on Shared Hosting Environment | FastComet\" \/>\n<meta property=\"og:description\" content=\"What is WP-CLI? What is WP-CLI used for? \u261b Learn how to use the set of command-line tools for managing your WordPress installations.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.fastcomet.com\/blog\/wp-cli-on-shared-hosting\" \/>\n<meta property=\"og:site_name\" content=\"FastComet Blog\" \/>\n<meta property=\"article:published_time\" content=\"2015-04-12T04:13:18+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-06-10T07:53:13+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.fastcomet.com\/blog\/wp-content\/uploads\/2015\/04\/wp-cli.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1024\" \/>\n\t<meta property=\"og:image:height\" content=\"645\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Christopher\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Christopher\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"WP-CLI Available on Shared Hosting Environment | FastComet","description":"What is WP-CLI? What is WP-CLI used for? \u261b Learn how to use the set of command-line tools for managing your WordPress installations.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.fastcomet.com\/blog\/wp-cli-on-shared-hosting","og_locale":"en_US","og_type":"article","og_title":"WP-CLI Available on Shared Hosting Environment | FastComet","og_description":"What is WP-CLI? What is WP-CLI used for? \u261b Learn how to use the set of command-line tools for managing your WordPress installations.","og_url":"https:\/\/www.fastcomet.com\/blog\/wp-cli-on-shared-hosting","og_site_name":"FastComet Blog","article_published_time":"2015-04-12T04:13:18+00:00","article_modified_time":"2022-06-10T07:53:13+00:00","og_image":[{"width":1024,"height":645,"url":"https:\/\/www.fastcomet.com\/blog\/wp-content\/uploads\/2015\/04\/wp-cli.jpg","type":"image\/jpeg"}],"author":"Christopher","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Christopher","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.fastcomet.com\/blog\/wp-cli-on-shared-hosting#article","isPartOf":{"@id":"https:\/\/www.fastcomet.com\/blog\/wp-cli-on-shared-hosting"},"author":{"name":"Christopher","@id":"https:\/\/www.fastcomet.com\/blog\/#\/schema\/person\/e70bae8b5451b247e36928e336317827"},"headline":"WP-CLI Available on Shared Hosting Environment","datePublished":"2015-04-12T04:13:18+00:00","dateModified":"2022-06-10T07:53:13+00:00","mainEntityOfPage":{"@id":"https:\/\/www.fastcomet.com\/blog\/wp-cli-on-shared-hosting"},"wordCount":826,"commentCount":0,"image":{"@id":"https:\/\/www.fastcomet.com\/blog\/wp-cli-on-shared-hosting#primaryimage"},"thumbnailUrl":"https:\/\/www.fastcomet.com\/blog\/wp-content\/uploads\/2015\/04\/wp-cli.jpg","keywords":["cli","shared hosting"],"articleSection":["Service Updates","WordPress"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.fastcomet.com\/blog\/wp-cli-on-shared-hosting#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.fastcomet.com\/blog\/wp-cli-on-shared-hosting","url":"https:\/\/www.fastcomet.com\/blog\/wp-cli-on-shared-hosting","name":"WP-CLI Available on Shared Hosting Environment | FastComet","isPartOf":{"@id":"https:\/\/www.fastcomet.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.fastcomet.com\/blog\/wp-cli-on-shared-hosting#primaryimage"},"image":{"@id":"https:\/\/www.fastcomet.com\/blog\/wp-cli-on-shared-hosting#primaryimage"},"thumbnailUrl":"https:\/\/www.fastcomet.com\/blog\/wp-content\/uploads\/2015\/04\/wp-cli.jpg","datePublished":"2015-04-12T04:13:18+00:00","dateModified":"2022-06-10T07:53:13+00:00","author":{"@id":"https:\/\/www.fastcomet.com\/blog\/#\/schema\/person\/e70bae8b5451b247e36928e336317827"},"description":"What is WP-CLI? What is WP-CLI used for? \u261b Learn how to use the set of command-line tools for managing your WordPress installations.","breadcrumb":{"@id":"https:\/\/www.fastcomet.com\/blog\/wp-cli-on-shared-hosting#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.fastcomet.com\/blog\/wp-cli-on-shared-hosting"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.fastcomet.com\/blog\/wp-cli-on-shared-hosting#primaryimage","url":"https:\/\/www.fastcomet.com\/blog\/wp-content\/uploads\/2015\/04\/wp-cli.jpg","contentUrl":"https:\/\/www.fastcomet.com\/blog\/wp-content\/uploads\/2015\/04\/wp-cli.jpg","width":1024,"height":645},{"@type":"BreadcrumbList","@id":"https:\/\/www.fastcomet.com\/blog\/wp-cli-on-shared-hosting#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.fastcomet.com\/blog"},{"@type":"ListItem","position":2,"name":"WP-CLI Available on Shared Hosting Environment"}]},{"@type":"WebSite","@id":"https:\/\/www.fastcomet.com\/blog\/#website","url":"https:\/\/www.fastcomet.com\/blog\/","name":"FastComet Blog","description":"FastComet Web Hosting Blog","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.fastcomet.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.fastcomet.com\/blog\/#\/schema\/person\/e70bae8b5451b247e36928e336317827","name":"Christopher","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.fastcomet.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/99f135e26f1ad748551251c1956e4aae0bd3bcc11af8e071075359b134894941?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/99f135e26f1ad748551251c1956e4aae0bd3bcc11af8e071075359b134894941?s=96&d=mm&r=g","caption":"Christopher"},"description":"Christopher has many years of experience leading teams in the fields of Technical support, Server Administration, and Product Development. He mainly works on the backend, helping to create the infrastructure that powers FastComet. He is responsible for flawless migrations and quick and efficient answers to client questions. He also monitors our network status and jumps in to solve time-sensitive issues like DDoS attacks and stops malicious attempts in their tracks. Christopher\u2019s primarily responsible for making sure that our servers purr along, and has worked tirelessly to improve automation at FastComet.","sameAs":["https:\/\/www.fastcomet.com"],"url":"https:\/\/www.fastcomet.com\/blog\/author\/christopher"}]}},"_links":{"self":[{"href":"https:\/\/www.fastcomet.com\/blog\/wp-json\/wp\/v2\/posts\/229","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.fastcomet.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fastcomet.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.fastcomet.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fastcomet.com\/blog\/wp-json\/wp\/v2\/comments?post=229"}],"version-history":[{"count":14,"href":"https:\/\/www.fastcomet.com\/blog\/wp-json\/wp\/v2\/posts\/229\/revisions"}],"predecessor-version":[{"id":4263,"href":"https:\/\/www.fastcomet.com\/blog\/wp-json\/wp\/v2\/posts\/229\/revisions\/4263"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.fastcomet.com\/blog\/wp-json\/wp\/v2\/media\/591"}],"wp:attachment":[{"href":"https:\/\/www.fastcomet.com\/blog\/wp-json\/wp\/v2\/media?parent=229"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fastcomet.com\/blog\/wp-json\/wp\/v2\/categories?post=229"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fastcomet.com\/blog\/wp-json\/wp\/v2\/tags?post=229"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}