In this tutorial, we are going to create a WordPress workflow. What does that mean? It means your WordPress website will go live. In the previous tutorial, you set up your local WordPress development environment with Vagrant, VVV, and Variable VVV. Now, you’ll push your site to a server with a tool called WordMove.As a quick side note, I am using a MacBook Pro running El Capitan, and my host is Host Gator.
WordMove is an incredible tool for the perfect WordPress workflow. With one command, you can push your entire local WordPress site to your server (database and all).
Before we start, I’ll mention that in this tutorial, we’ll be using Vagrant and VVV. If you already have this local development environment set up, great job! If not, you can follow to steps to setting up your local WordPress development environment in my previous tutorial.
In that tutorial, we downloaded and installed Virtual Box, Vagrant, Varying Vagrant Vagrants (VVV for short), and a tool called Variable VVV.
You’ll start off by installing WordMove into the Vagrant box called VVV (Varying Vagrant Vagrants, a Vagrant box optimized for WordPress development). In the previous tutorial, we downloaded VVV to a folder called vagrant-local in our home directory. I’ll assume that is where you also downloaded it. If you haven’t already, start your Vagrant box by running the command
vagrant up in vagrant-local.
Next, in the folder called provision inside of your VVV download (vagrant-local>provision), create a file called provision-pre.sh and add the following code to it.
# Rubygems update if [ $(gem -v|grep '^2.') ]; then echo "gem installed" else apt-get install -y ruby-dev echo "ruby-dev installed" echo "gem not installed" gem install rubygems-update update_rubygems fi # wordmove install wordmove_install="$(gem list wordmove -i)" if [ "$wordmove_install" = true ]; then echo "wordmove installed" else echo "wordmove not installed" gem install wordmove wordmove_path="$(gem which wordmove | sed -s 's/.rb/\/deployer\/base.rb/')" if [ "$(grep yaml $wordmove_path)" ]; then echo "can require yaml" else echo "can't require yaml" echo "set require yaml" sed -i "7i require\ \'yaml\'" $wordmove_path echo "can require yaml" fi fi
The code and instructions explaining how to provision Vagrant with WordMove can also be found at this website.
Save the file, open up your terminal, navigate to vagrant-local, and run
This will install WordMove into your Vagrant box.
You may be wondering why you can’t just install WordMove outside of Vagrant. The reason is that I ran into too many errors running it locally, and then found out that it is recommended to run it in Vagrant.
Creating the WordPress Site with Variable VVV
Since starting form scratch is the best way to learn things, we’ll create a clean WordPress installation inside of VVV with a tool called Variable VVV (see my previous tutorial for more instructions on Variable VVV).
Navigate to the the folder where VVV keeps its local WordPress sites (
cd ~/vagrant-local/www) and run the command
You’ll be asked a couple questions, but just keep the default settings. One of the questions it will ask is for the name of the site. Name your site “test” and enter your computer’s password.
Go back into VVV (your Vagrant box) with
vagrant ssh and navigate to your new WordPress site (
wordmove init to create a Movefile in the htdocs directory (your current working directory).
For editing the Movefile, I recommend using Sublime Text 3. You can use your text editor, but I wouldn’t recommend it.
Configuring the Movefile and Deploying
Big side note here: if you know what you’re doing in the Movefile, just fill it out and continue. For the rest of us, I created another tutorial specifically for filling out the Movefile. I cut it out from this tutorial due to the amount of space it was taking up.
Now that you’ve set up your Movefile (whether on your own or with the separate tutorial), you can push your local site to your server.
While you’re still inside of your Vagrant box, in your terminal, run
wordmove push -e production --all.
You will be asked to enter your password about five times while it does its stuff. I know. It’s tedious, but you can set up SSH to bypass it, later, at the end of this tutorial.
After it pushes your local site, you should be able to visit your live site (test.com) and see an exact copy of your local site (database and all).
If your homepage works, but none of your other links work (404 error), go to the admin area, click Settings (in the left side bar) > Permalinks > click Save Changes. After that, your 404 errors should go away.
If you get a 500 error, a temporary solution is to SSH into your server’s public_html file which will be different for each server, but, generally, it will include the work “public.” In that folder, run the following commands:
find * -type d -print0 | xargs -0 chmod 0755 # for directories
find . -type f -print0 | xargs -0 chmod 0644 # for files
After that, your file and folder permissions should be corrected. For me, the error was fixed by changing the local wordpress_path to /vagrant/www instead of /srv/www and pushing the site, again.
You can use the command
wordmove pull -e production --all to pull changes from your site.
A note of warning: Wordmove does not work like git and will not merge changes from your local site to your live site if work has been done on both the live site and local site. If you push your local site, WordMove will overwrite everything (and I mean everything) on your live site with the information from your local site. The same goes if you makes changes locally and pull in changes from your live site. Your local site will be overwritten with the information from the live site.
Enabling SSH with VVV
If you don’t want to type your password five times whenever you need to push or pull a WordPress site, first, you’ll need to follow this tutorial on How to SSH into Host Gator/Any Server. After you’ve completed that tutorial, all you need to do is copy the contents of id_rsa to VVV.
First, copy the contents of the id_rsa file that you created in the linked tutorial. Next, open your terminal and run
cd vagrant-local to enter the folder where VVV was downloaded. Run
vagrant ssh to enter the Vagrant box (VVV). Inside the Vagrant box, navigate to the .ssh folder in Vagrant’s home folder:
cd ~/.ssh. Create a file called id_rsa:
touch id_rsa. Open the file with vi:
vi id_rsa. Press
i to start insert mode. Press command + v to paste the contents of id_rsa that you copied earlier to the file. Exit insert mode by pressing Esc. Then, type
:wq to save the file and quit vi.
In order for Vagrant to use this new file, you’ll also have to change its permissions. In your terminal, run
chmod 400 id_rsa to change the file permissions.
Now, when you push or pull your WordPress site, you won’t have to enter your password five times.
That’s pretty much it! You, now, have an incredibly fast and reliable WordPress development environment and workflow! I am genuinely happy for you. It was a lot of work, but, now, you can enjoy the fruits of your labor.