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

Configuring WordPress

  • Create an empty project folder on you local machine:
    /path/to/projects/directory/[project-name]
  • 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).

Configuring Sage

Since WP Engine doesn’t provide npm, gulp, bower, etc on the hosting service, the compiled assets and the front end libraries (css and javascript) should be versioned and pushed to the repository in order to be available in the online website:

  • 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.

Configuring Git

  • 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 git@git.wpengine.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:
    cat ~/.ssh/id_rsa.pub

    It should looks like this:

    ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAklOUpkDHrfHY17SbrmTIpNLTGK9Tjom/BWDSUGPl+nafzlHDTYW7hdI4yZ5ew18JH4JW9jbhUFrviQzM7xlELEVf4h9lFX5QVkbPppSwg0cda3Pbv7kOdJ/MTyBlWXFCR+HAo3FXRitBqxiX1nKhXpHAZsMciLq8V6RjsNAQwdsdMFvSlVK/7XAt3FaoJoAsncM1Q9x5+3V0Ww68/eIFmb1zuUFljQJKprrX88XypNDvjYNby6vw/Pb0rwert/EnmZ+AW4OZPnTPI89ZPmVMLuayrD2cE86Z/il8b+gw3r3+1nKatmIkjn2so1d01QraTlMqVSsbxNrRFi9wrf+M7Q== schacon@mylaptop.local
  • 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 git@git.wpengine.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 git@git.wpengine.com:production/[project-name].git
  • Copy wp-config.php.example to wp-config.php and set your local settings.
  • Load the database’s dump.

References

https://wpengine.com/git/
http://wpengine.com/blog/best-practice-wp-engines-git-push/
http://blog.devteaminc.co/deploying-a-wordpress-site-on-wpengine-using-git/
http://alwaysbedoing.com/thoughts/how-to-start-a-new-wordpress-project-on-wp-engine-using-git/

WordPress upgrades
http://wpengine.com/blog/one-click-wordpress-core-upgrade/
https://wpengine.com/support/wordpress-updates/

Categories

Category BootstrapCategory CoffeescriptCategory DrupalCategory GravCategory HTMLCategory JavascriptCategory JoomlaCategory jQueryCategory LaravelCategory MagentoCategory PHPCategory SharePointCategory SpringCategory ThymeleafCategory WordPressCategory Workflow

Comments

Developed and designed by Netgloo
© 2016 Netgloo