One of the most important challenge in WordPress development is to move local WordPress installation to remote servers. This is a critical step in transferring test or finished code to staging or live servers.
In this article, I will introduce WordMove, a very popular tool for mirroring the local WordPress installation to the remote servers. The best thing about WordMove is that it takes care of syncing code and databases with staging or live servers.
For many developers, two important aspects of the tool is the complete support for SSH connections and the ease of pulling or pushing the environment through simple commands. you can easily pull or push the environment back and forth with simple commands.
Prerequisites & Notes
1- Make sure you have rsync installed.
2- sshpass must be installed in order to have Wordmove use the ssh details provided in the Movefile.
3- We have tested WordMove on Linux and written this guide accordingly.
Install the Ruby Virtual Machine (RVM)
Installation of WordMove depends upon RVM because Wordmove primarily depends upon Ruby 2.0 or higher. I will set up the environment before getting started.
By default, RVM is not installed on Linux platforms. So, before installing RVM, I will import the public key into our system, and then use Curl to install RVM in the system:
$ gpg --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3
$ curl -sSL https://get.rvm.io | bash -s stable
After installing RVM, I will setup RVM environment so that the current shell takes up new environment settings.
$ source /etc/profile.d/rvm.sh
Install all the dependencies for installing Ruby automatically on the system:
$ rvm requirements
$ rvm install 2.2.4
$ rvm use 2.2.4 --default
The next step is the installation of WordMove using GEM
$ gem install wordmove
I faced some issues while running this command. Here are several tips for handling the issues:
$ sudo gem install wordmove
returns net-ssh requires Ruby version >= 2.0
To solve this issue, just make the Ruby directory publicly writeable:
$sudo chmod -R 777 /usr/local/rvm/gems/ruby-2.3.0
Set up WordMove
WordMove maintains a config file, and a SSH connection. This determines the folders and files need to be synched. Here is a sample WordMove File named Movefile.
wordpress_path: "/home/syednoorali/MyTasks/cloudways/WordMove/" # use an absolute path here
user: "LOCAL USER"
password: "LOCAL USER PASS"
# paths: # you can customize wordpress internal paths
# wp_content: "wp-content"
# uploads: "wp-content/uploads"
# plugins: "wp-content/plugins"
# themes: "wp-content/themes"
# languages: "wp-content/languages"
wordpress_path: "/home/11111-22222.cloudwaysapps.com/xxxxxx/public_html/" # use an absolute path here
name: "DB NAME"
user: "DB USER"
password: "DB PASS"
port: "3306" # Use just in case you have exotic server config
# mysqldump_options: "--result-file=/applications/ydnzcdfyhd/public_html/wp-content/dump.sql" # Only available if using SSH
host: "Server IP"
user: "SERVER USERNAME"
password: "SERVER PASS"
I will now detail simple commands to push or pull code:
$ wordmove push --all #this will sync local -> remote
$ wordmove pull --all #this will sync remote -> local
You could define multiple environment for deploying to WordPress website.
Parameters could also be used when pulling and pushing the files:
$ wordmove push --all -w -e staging
$ wordmove push --all -w -e deployment
In addition, WordMove integrated an incremental approach and after the initial synchronization, only unsynced files are pushed or pulled.
All these commands also work equally well for databases. I have tested the following scenarios:
- Created a new table in the remote database. Next, I ran a local push, which only caused changes in existing tables and left the newly created table as it was. Note that the new table did not exist locally.
- Created a new table in the local database. Next, I ran a remote pull, which only caused changes in the existing tables and left the newly created table as it was. Note that the new table did not exist remotely.
- Created a new table in the remote database and then ran a remote pull, which brought the newly created table into the local database.
- Created a new table in the local database and then ran a local push, which pushed the changes in the newly created table to the remote database.
WordMove is a very important tool for moving local WordPress installations to staging and remote servers. The move is very streamlined and works without a hitch in almost all cases. I would recommend that you try out WordMove for your next project. If you face any issues or would like to contribute to the discussion, do leave a comment below.
Make Your WordPress Website 100% Faster.
Host it now on Cloudways WordPress Hosting Platform.