Wordpress Cli



There are a few ways to change the main WordPress domain URL of a site – here is how to do it with the WP-CLI tool, which is probably the fastest and less problematic way of doing it.

  1. Wordpress Client Login Plugin
  2. Wordpress Client Dashboard

The WP-CLI is a tool that enables you to interact with your WordPress site directly by using commands in a text-based interface. It’s also very comprehensive, featuring a wide variety of potential commands. Almost anything you can do on the back end of your site, you can do much faster using the WP-CLI. WP-CLI can be used to manage WordPress plugins from the command line. This is useful for scripting or automating the management of your plugins. For example, with WP-CLI you could automatically check if there is an update for your plugins and upgrade them if there is a new version. If you have not used it yet, WP-CLI is an efficient way to manage your WordPress installation using a command line interface, meaning you type text commands like these two: wp core update wp plugin update-all.

PluginWordpress Cli

You’ll need to access your webhost via a shell session over SSH, once there switch directory to your web root folder such as public_html or htdocs

Test to see if you have wp-cli installed

You should see output

Wordpress Client Login Plugin

The format for the command is wp search-replace ‘olddomain’ ‘newdomain’

You can test the command with a dry run before doing it live like so…

Also you can swap http to https

Take a Database Backup

Cli

You may want to take a database back also before you commit to the changes, do so like this

This will export the database to the current webroot directory, probably not a good idea to leave it there. It will be named along the lines of…

To import that database back (whilst still in the webroot directory) and override the original use…

A succesful import will give output…

If you can’t get a shell or command line access or don’t have wp-cli there are alternatives you can try such as WP Migrate Pro, Better Search and Replace, interconnectit Search & Replace or manually in phpMyAdmin or MySQL – see a write on these here.

Before running the commands shown on this page, you should load the Bitnami stack environment by executing the installdir/use_APPNAME script (Linux and MacOS) or by clicking the shortcut in the Start Menu under “Start -> Bitnami APPNAME Stack -> Application console” (Windows). On OS X VMs, the installation directory is /opt/bitnami and OS X VM users can click the “Open Terminal” button to run commands. Learn more about the Bitnami stack environment and about OS X VMs.

WP-CLI is the command-line interface for WordPress. You can update plugins, configure multisite installs and much more, without using a Web browser. It is already included with the Bitnami solution so you can start using it easily. In order to check that everything is working properly, you can run the info command:

Wordpress Cli

NOTE: The wp utility is also included in the system path so you can run the command without specifying the whole path to the file.

To update WordPress using WP-CLI, you need to allow WP-CLI to perform the operation as the root user, as shown below:

Wordpress Client Dashboard

As that command changes the ownership of some files to root, you need to reset the file ownership and then restart Apache for the update to take effect: