{"id":6351,"date":"2023-07-31T06:13:00","date_gmt":"2023-07-31T06:13:00","guid":{"rendered":"https:\/\/www.smarthost.au\/blog\/?p=6351"},"modified":"2024-06-18T11:05:53","modified_gmt":"2024-06-18T11:05:53","slug":"how-to-install-wp-cli-on-smarthost-eu-servers","status":"publish","type":"post","link":"https:\/\/www.smarthost.au\/blog\/how-to-install-wp-cli-on-smarthost-eu-servers","title":{"rendered":"How to install wp-cli on smarthost.eu servers?"},"content":{"rendered":"\n<p>To install wp-cli you must first enable ssh access. Here is a guide on how to do that: <a href=\"https:\/\/www.smarthost.eu\/is-ssh-access-available-on-hosting-accounts\">Is SSH access available on hosting accounts?<\/a><\/p>\n\n\n\n<p><strong>IMPORTANT: ssh access works for all accounts. To get ssh access on a test account, contact us at hosting@smarthost.eu<\/strong><\/p>\n\n\n\n<p>Then on Windows, we log in to ssh using a client, e.g. PUTTY, it is free and can be downloaded from the website:<\/p>\n\n\n\n<p>&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/www.chiark.greenend.org.uk\/~sgtatham\/putty\/latest.html\" target=\"_blank\">https:\/\/www.chiark.greenend.org.uk\/~sgtatham\/putty\/latest.html<\/a><\/p>\n\n\n\n<p>Linux users can log in using the terminal using the command below:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><strong>ssh -p 5739 login@client-name.smarthost.eu<\/strong><\/p>\n<\/blockquote>\n\n\n\n<p>Install and run the program. We enter our cPanel login in the first field, then @, then the name of our account at Smarthost.eu. In the second field, enter port <strong>5739<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"599\" height=\"542\" src=\"https:\/\/www.smarthost.au\/blog\/wp-content\/uploads\/2024\/06\/cli1.png\" alt=\"\" class=\"wp-image-6428\" srcset=\"https:\/\/www.smarthost.au\/blog\/wp-content\/uploads\/2024\/06\/cli1.png 599w, https:\/\/www.smarthost.au\/blog\/wp-content\/uploads\/2024\/06\/cli1-300x271.png 300w, https:\/\/www.smarthost.au\/blog\/wp-content\/uploads\/2024\/06\/cli1-520x471.png 520w\" sizes=\"auto, (max-width: 599px) 100vw, 599px\" \/><\/figure>\n\n\n\n<p>First, make sure that you are in the default directory, e.g. \/home\/client-login, using the <strong>pwd<\/strong> command<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"661\" src=\"https:\/\/www.smarthost.au\/blog\/wp-content\/uploads\/2024\/06\/cli2-1024x661-2.png\" alt=\"\" class=\"wp-image-6430\" srcset=\"https:\/\/www.smarthost.au\/blog\/wp-content\/uploads\/2024\/06\/cli2-1024x661-2.png 1024w, https:\/\/www.smarthost.au\/blog\/wp-content\/uploads\/2024\/06\/cli2-1024x661-2-300x194.png 300w, https:\/\/www.smarthost.au\/blog\/wp-content\/uploads\/2024\/06\/cli2-1024x661-2-768x496.png 768w, https:\/\/www.smarthost.au\/blog\/wp-content\/uploads\/2024\/06\/cli2-1024x661-2-520x336.png 520w, https:\/\/www.smarthost.au\/blog\/wp-content\/uploads\/2024\/06\/cli2-1024x661-2-740x478.png 740w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Then download wp-cli with the wget command:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><strong>wget https:\/\/raw.githubusercontent.com\/wp-cli\/builds\/gh-pages\/phar\/wp-cli.phar<\/strong><\/p>\n<\/blockquote>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"865\" height=\"417\" src=\"https:\/\/www.smarthost.au\/blog\/wp-content\/uploads\/2024\/06\/cli3.png\" alt=\"\" class=\"wp-image-6431\" srcset=\"https:\/\/www.smarthost.au\/blog\/wp-content\/uploads\/2024\/06\/cli3.png 865w, https:\/\/www.smarthost.au\/blog\/wp-content\/uploads\/2024\/06\/cli3-300x145.png 300w, https:\/\/www.smarthost.au\/blog\/wp-content\/uploads\/2024\/06\/cli3-768x370.png 768w, https:\/\/www.smarthost.au\/blog\/wp-content\/uploads\/2024\/06\/cli3-520x251.png 520w, https:\/\/www.smarthost.au\/blog\/wp-content\/uploads\/2024\/06\/cli3-740x357.png 740w\" sizes=\"auto, (max-width: 865px) 100vw, 865px\" \/><\/figure>\n\n\n\n<p><br><br>The next thing you need to do is edit the .bashrc. For this we can use the nano or mcedit editor. For the tutorial, I&#8217;ll use mcedit.<br><\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><strong>mcedit .bashrc<\/strong><\/p>\n<\/blockquote>\n\n\n\n<p>After executing the above command, the editor window should appear<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"708\" height=\"434\" src=\"https:\/\/www.smarthost.au\/blog\/wp-content\/uploads\/2024\/06\/cli4.png\" alt=\"\" class=\"wp-image-6432\" srcset=\"https:\/\/www.smarthost.au\/blog\/wp-content\/uploads\/2024\/06\/cli4.png 708w, https:\/\/www.smarthost.au\/blog\/wp-content\/uploads\/2024\/06\/cli4-300x184.png 300w, https:\/\/www.smarthost.au\/blog\/wp-content\/uploads\/2024\/06\/cli4-520x319.png 520w\" sizes=\"auto, (max-width: 708px) 100vw, 708px\" \/><\/figure>\n\n\n\n<p><br>Due to the ability to choose the PHP version on hosting accounts, you decide which PHP version wp-cli should use. For this purpose, we add a command alias to make it easier to navigate and choose the php version. The path \/home\/loginclient is the path where we downloaded the wp-cli. Important: You should only choose one from the list below, for the php version you are using and write it under <\/p>\n\n\n\n<p># User specific aliases and functions<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<pre class=\"wp-block-code\"><code>PHP 5.6\n\nalias wp='\/opt\/cpanel\/ea-php56\/root\/usr\/bin\/php \/home\/clientlogin\/wp-cli.phar'\n\nPHP 7.0\n\nalias wp='\/opt\/cpanel\/ea-php70\/root\/usr\/bin\/php \/home\/clientlogin\/wp-cli.phar'\n\nPHP 7.1\n\nalias wp='\/opt\/cpanel\/ea-php71\/root\/usr\/bin\/php \/home\/clientlogin\/wp-cli.phar'\n\nPHP 7.2\n\nalias wp='\/opt\/cpanel\/ea-php72\/root\/usr\/bin\/php \/home\/clientlogin\/wp-cli.phar'\n\nPHP 7.3\n\nalias wp='\/opt\/cpanel\/ea-php73\/root\/usr\/bin\/php \/home\/clientlogin\/wp-cli.phar'\n\nPHP 7.4\n\nalias wp='\/opt\/cpanel\/ea-php74\/root\/usr\/bin\/php \/home\/clientlogin\/wp-cli.phar'\n\nPHP 8.0\n\nalias wp='\/opt\/cpanel\/ea-php80\/root\/usr\/bin\/php \/home\/clientlogin\/wp-cli.phar'\n\nPHP 8.1\n\nalias wp='\/opt\/cpanel\/ea-php81\/root\/usr\/bin\/php \/home\/clientlogin\/wp-cli.phar'\n\nPHP 8.2\n\nalias wp='\/opt\/cpanel\/ea-php82\/root\/usr\/bin\/php \/home\/clientlogin\/wp-cli.phar'<\/code><\/pre>\n<\/div><\/div>\n<\/blockquote>\n\n\n\n<p><br>\nUse the F2 key to save and then use F10 to exit the editor.<br><br> The last thing you need to do is load the configuration in the current session. New SSH sessions will automatically load the configuration.<br><\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><strong>. .bashrc<\/strong><\/p>\n<\/blockquote>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"661\" src=\"https:\/\/www.smarthost.au\/blog\/wp-content\/uploads\/2024\/06\/cli5-1024x661-1.png\" alt=\"\" class=\"wp-image-6433\" srcset=\"https:\/\/www.smarthost.au\/blog\/wp-content\/uploads\/2024\/06\/cli5-1024x661-1.png 1024w, https:\/\/www.smarthost.au\/blog\/wp-content\/uploads\/2024\/06\/cli5-1024x661-1-300x194.png 300w, https:\/\/www.smarthost.au\/blog\/wp-content\/uploads\/2024\/06\/cli5-1024x661-1-768x496.png 768w, https:\/\/www.smarthost.au\/blog\/wp-content\/uploads\/2024\/06\/cli5-1024x661-1-520x336.png 520w, https:\/\/www.smarthost.au\/blog\/wp-content\/uploads\/2024\/06\/cli5-1024x661-1-740x478.png 740w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><br>After all these steps, we can test the operation of wp-cli with the following command.<br><\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><strong>wp \u2013info<\/strong><\/p>\n\n\n\n<p>OS: Linux 4.18.0-477.10.1.lve.el8.x86_64 #1 SMP Wed May 17 07:12:55 EDT 2023 x86_64<br>Shell: \/bin\/bash<br>PHP binary: \/opt\/cpanel\/ea-php82\/root\/usr\/bin\/php.cagefs<br>PHP version: 8.2.7<br>php.ini used: \/opt\/cpanel\/ea-php82\/root\/etc\/php.ini<br>MySQL binary: \/usr\/bin\/mysql<br>MySQL version: mysql Ver 8.0.33 for Linux on x86_64 (MySQL Community Server &#8211; GPL)<br>SQL modes:<br>WP-CLI root dir: phar:\/\/wp-cli.phar\/vendor\/wp-cli\/wp-cli<br>WP-CLI vendor dir: phar:\/\/wp-cli.phar\/vendor<br>WP_CLI phar path: \/home\/mickry<br>WP-CLI packages dir:<br>WP-CLI cache dir: \/home\/mickry\/.wp-cli\/cache<br>WP-CLI global config:<br>WP-CLI project config:<br>WP-CLI version: 2.8.1<\/p>\n\n\n\n<p><\/p>\n<\/blockquote>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"663\" src=\"https:\/\/www.smarthost.au\/blog\/wp-content\/uploads\/2024\/06\/cli6-1024x663-1.png\" alt=\"\" class=\"wp-image-6434\" srcset=\"https:\/\/www.smarthost.au\/blog\/wp-content\/uploads\/2024\/06\/cli6-1024x663-1.png 1024w, https:\/\/www.smarthost.au\/blog\/wp-content\/uploads\/2024\/06\/cli6-1024x663-1-300x194.png 300w, https:\/\/www.smarthost.au\/blog\/wp-content\/uploads\/2024\/06\/cli6-1024x663-1-768x497.png 768w, https:\/\/www.smarthost.au\/blog\/wp-content\/uploads\/2024\/06\/cli6-1024x663-1-520x337.png 520w, https:\/\/www.smarthost.au\/blog\/wp-content\/uploads\/2024\/06\/cli6-1024x663-1-740x479.png 740w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>To install wp-cli you must first enable ssh access. Here is a guide on how to do that: Is SSH access available on hosting accounts? IMPORTANT: ssh access works for all accounts. To get ssh<a class=\"read-more\" href=\"https:\/\/www.smarthost.au\/blog\/how-to-install-wp-cli-on-smarthost-eu-servers\">Continue reading<\/a><\/p>\n","protected":false},"author":20,"featured_media":6352,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1021,39],"tags":[1127,1128,294,63,1096],"class_list":["post-6351","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-guides","category-wordpress","tag-diffrent-versions","tag-diffrent-versions-of-php","tag-php-hr","tag-wordpress","tag-wp-cli"],"_links":{"self":[{"href":"https:\/\/www.smarthost.au\/blog\/wp-json\/wp\/v2\/posts\/6351","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.smarthost.au\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.smarthost.au\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.smarthost.au\/blog\/wp-json\/wp\/v2\/users\/20"}],"replies":[{"embeddable":true,"href":"https:\/\/www.smarthost.au\/blog\/wp-json\/wp\/v2\/comments?post=6351"}],"version-history":[{"count":2,"href":"https:\/\/www.smarthost.au\/blog\/wp-json\/wp\/v2\/posts\/6351\/revisions"}],"predecessor-version":[{"id":6435,"href":"https:\/\/www.smarthost.au\/blog\/wp-json\/wp\/v2\/posts\/6351\/revisions\/6435"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.smarthost.au\/blog\/wp-json\/wp\/v2\/media\/6352"}],"wp:attachment":[{"href":"https:\/\/www.smarthost.au\/blog\/wp-json\/wp\/v2\/media?parent=6351"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.smarthost.au\/blog\/wp-json\/wp\/v2\/categories?post=6351"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.smarthost.au\/blog\/wp-json\/wp\/v2\/tags?post=6351"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}