Using WP CLI To Deploy Sites Into Production

WP CLI is a command-line tool to manage your WordPress installations. With some shell scripting you have a powerful tool at your disposal to execute routing tasks managing WordPress. If you do not have shell access to your web-server, this article is not for you. There are two steps to deploying WordPress development installs into production:

  1. Install WP CLI
  2. Executing the right commands.

Installing WP CLI

The WP CLI can be downloaded from https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar. You can use any command-line tool like wget or curl to download it.

Test it with

php wp-cli.phar --info

This will output the wp-cli info which is self-explanatory.
Finally make it executable:

chmod +x wp-cli.phar

And move it to your directory containing the binaries:

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

Let’s verify that the WP CLI is now available globally:

wp --info

Executing the Search and Replace command

Dry Run

wp search-replace 'www.oldsite.com/directory' 'newsite.org' --dry-run --verbose --precise

Once you are satisfied, you can run the above command without the --dry-run option:
wp search-replace 'www.oldsite.com/directory' 'newsite.org' --verbose --precise

Comment on Using WP CLI To Deploy Sites Into Production

Your email address will not be published. Required fields are marked *