{"id":17159,"date":"2015-07-09T13:59:21","date_gmt":"2015-07-09T18:59:21","guid":{"rendered":"https:\/\/secure.rosehosting.com\/blog\/?p=17159"},"modified":"2022-07-15T05:15:22","modified_gmt":"2022-07-15T10:15:22","slug":"how-to-install-and-use-wp-cli-on-a-linux-vps","status":"publish","type":"post","link":"https:\/\/www.rosehosting.com\/blog\/how-to-install-and-use-wp-cli-on-a-linux-vps\/","title":{"rendered":"How to install and use WP-CLI on a Linux VPS"},"content":{"rendered":"
WP-CLI is a command line interface for managing WordPress installations. WP-CLI provides a set of command line tools for upgrading the WordPress core files, installing\/uninstalling themes or plugins, enabling\/disabling plugins and much more. Using the WP-CLI you will be able to keep your WordPress site up to date and keep your Linux VPS<\/a> safe and clean from malicious files.<\/p>\n <\/p>\n Today we are going to show you how to install and use WP-CLI on your server. You can use this guide if you have CentOS VPS<\/a> or Ubuntu VPS<\/a> with PHP 5.3.2 or later installed. Also, this guide applies if you are using WordPress 3.5.2 or later for your site.<\/p>\n First thing you need to do is to log in to your VPS via SSH<\/a>. Then, navigate to your ‘\/opt’ directory and download the ‘wp-cli.phar’ file. You can download the file using wget or curl. In this guide, we are using curl.<\/p>\n Now, you can check if the file works by running the following command:<\/p>\n Make the file executable and move it to the ‘\/usr\/local\/bin\/’ directory on your server. Also, you can rename the file to something more simple so you will not have to type ‘wp-cli.phar’ every time you like to manage your WordPress installation.<\/p>\n Once you execute these two commands, you are ready to use WP-CLI. First, navigate to the directory where your WordPress is installed. For example, if your WordPress is installed in the ‘\/var\/www\/html\/wordpress\/’ directory, you can type:<\/p>\n To check the version of your WordPress installation, you can execute the following command:<\/p>\n You will get something like this:<\/p>\n This means that your WordPress version is 4.2, which is the latest version of WordPress at the moment of writing this tutorial. Therefore, if you try to update your core version using the command<\/p>\n you will get the following result:<\/p>\n To update all your themes and plugins, you can execute the commands written below:<\/p>\n Similarly, you can install\/uninstall plugins and themes. For example, to install the wordfence plugin, you can use the following command:<\/p>\n To activate the plugin, you can run the following command:<\/p>\n To list the installed plugins, both enabled and disabled, execute:<\/p>\n The same applies for your WordPress themes.<\/p>\n More information about how to use WP-CLI on your Linux VPS<\/a> you can find if you run the following command:<\/p>\n or, if you visit the official web site at:<\/p>\n Of course you don\u2019t have to do any of this if you use one of our Linux VPS hosting services<\/a>, in which case you can simply ask our expert Linux admins to install WP-CLI for you. They are available 24\u00d77 and will take care of your request immediately.<\/p>\n PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.<\/p>\n","protected":false},"excerpt":{"rendered":" WP-CLI is a command line interface for managing WordPress installations. WP-CLI provides a set of command line tools for upgrading … <\/p>\ncd \/opt\r\ncurl -O https:\/\/raw.githubusercontent.com\/wp-cli\/builds\/gh-pages\/phar\/wp-cli.phar<\/pre>\n
php wp-cli.phar --info<\/pre>\n
chmod +x wp-cli.phar\r\nsudo mv wp-cli.phar \/usr\/local\/bin\/wp<\/pre>\n
cd \/var\/www\/html\/wordpress<\/pre>\n
wp core version<\/pre>\n
[root@host] wp core version\r\n4.2\r\n<\/pre>\n
wp core update<\/pre>\n
[root@host] wp core update\r\nSuccess: WordPress is up to date.<\/pre>\n
wp theme update --all\r\nwp plugin update --all<\/pre>\n
wp plugin install wordfence<\/pre>\n
wp plugin activate wordfence<\/pre>\n
wp plugin list<\/pre>\n
wp --help<\/pre>\n
http:\/\/wp-cli.org\/<\/a><\/pre>\n