Workflow configurations for WP Engine, WordPress, Sage and Git
In the following are described steps and configurations for using the WP Engine hosting service with Git for deploying your WordPress website, using Sage for the theme development.
First configuration for a new website
- Create an empty project folder on you local machine:
- Download the website’s backup from WP Engine: go to the WP Engine’s admin panel (https://my.wpengine.com), then: Installs > Backup Points > Download Zip
- Copy the backup content (the WordPress website) to your local project folder.
- Delete the mu-plugin folder.
- Copy your custom wp-content inside the project folder (removing the WP Engine’s wp-content).
- Change the wp-config.php with your local configurations:
define( 'DB_NAME', '[db-name]' ); define( 'DB_USER', '[db-user]' ); define( 'DB_PASSWORD', '[db-user-password]' ); define( 'DB_HOST', 'localhost' ); define( 'DB_HOST_SLAVE', 'localhost' );
- Make a copy of your wp-config.php naming it wp-config.php.example (the wp-config.php will be excluded from Git, so you can share it with Git as wp-config.php.example).
- Remove the dist folder from the Sage’s .gitignore file (inside wp-content/themes/[project-name]).
Note: when you will push the code to WP Engine you have to remember to do the
gulp --production before to commit the code.
- Download the WP Engine’s .gitignore file from here choosing to keep WordPress core files versioned (here the direct link).
- Copy the .gitignore inside the project’s root folder.
Create the Git repository
- Go on the project folder and create your local repository:
cd [project] git init
- Optional: push the project on your (internal) Git server:
# Add the server's URL git remote add origin ssh://[git-user]@[server-addr]/path/to/[project-name].git # Make the first commit and push the project on the server git add --all git commit -a -m "Initial commit message" git push -u origin master
- Add the WP Engine remote:
git remote add production email@example.com:production/[wpengine-project-name].git
You will push your site to WP Engine with
git push production master.
See here other useful Git commands.
Configuring WP Engine
- Get your SSH public key:
It should looks like this:
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAklOUpkDHrfHY17SbrmTIpNLTGK9Tjom/BWDSUGPl+nafzlHDTYW7hdI4yZ5ew18JH4JW9jbhUFrviQzM7xlELEVf4h9lFX5QVkbPppSwg0cda3Pbv7kOdJ/MTyBlWXFCR+HAo3FXRitBqxiX1nKhXpHAZsMciLq8V6RjsNAQwdsdMFvSlVK/7XAt3FaoJoAsncM1Q9x5+3V0Ww68/eIFmb1zuUFljQJKprrX88XypNDvjYNby6vw/Pb0rwert/EnmZ+AW4OZPnTPI89ZPmVMLuayrD2cE86Z/il8b+gw3r3+1nKatmIkjn2so1d01QraTlMqVSsbxNrRFi9wrf+M7Q== firstname.lastname@example.org
- Go to the WP Engine’s admin panel, then: Installs > [project-name] > Git Push. Add here your name and your SSH public key. Wait about 10 minutes for WP Engine publishes the key.
- Test the connection with WP Engine:
ssh email@example.com info
If it’s ok will be output something like this:
hello [your ssh pub key name] R W production/sitename R W staging/sitename
See here for more details.
Commit and push to WP Engine
Compile assets with Gulp for production:
$ gulp --production
Commit and push the code to WP Engine with:
# Commit $ git add --all $ git commit -am "commit message" # Push $ git push production master
The code will be pushed to the WP Engine repository. When the push is successfully finished will be executed a script for copying the code from the Git repository to the website directory.
Database and uploads folder
For the database and the uploads folder (wp-content/uploads) must be still used some FTP.
- Upload the database dump with phpMyAdmin
- Upload the script for replacing the URLs with SFTP and launch the script.
- Upload the uploads folder with SFTP.
Cloning the project from WP Engine
- Create the user and add the SSH public key to WP Engine. Wait about 10 minutes.
- Clone the project locally with:
git clone firstname.lastname@example.org:production/[project-name].git
wp-config.phpand set your local settings.
- Load the database’s dump.