This is an example for when we WORK on Production. Pushing directly to production is an option for projects that are completely new and there is no content on it.

When

  • If this is complete new website.
  • No data migration will be done to this site other than manual content adding.
  • Data will only be added once development has stopped.

Why:

  • If everything is built on production then launching this website will be done without any effort.
  • No need to use WP Engine buttons to [Delpoy] to production from stage.
  • No stage URL will ever end-up on production.
  • Stage can be used as a backup of the DB.

How:

You will set up WP engine production on your local environment, and you will push to it directly skipping Stage. You will set up Stage as a Remote so one everything is done you can push to Stage from your local environment everything you have.

Before Setup:

Setup step by step:

  1. Navigate to folder where you are setting up you local environment
    $ cd ~/..wordpress../my_wp_install_name
  2. Clone Production from WP Engine

    $ git clone --recursive git@git.wpengine.com:production/INSTALLNAME.git .
  3. Set up your Stage as remote.
    $ git remote add INSTALLNAME-stage git@git.wpengine.com:staging/INSTALLNAME.git
  4. Fetch remote Stage
    $ git fetch INSTALLNAME-stage
  5. Add special .gitignore file to root directory
    • This ignores all of WP core because WP engine handles core updates, we will not be putting core in git
    • On your local you will install core using WP-CLI later on
  6. Push .gitignore to WP Engine repository from here https://gist.github.com/lehelmatyus/7ca04af6be50c8f48dfb81dd8c5913e4
  7. Install local instance of WordPress using WP-CLI
    $ wp core download
  8. Get The DB from WP Engine
    • Go to WP Engine Interface and navigate to phpMyAdmin link should be (https://my.wpengine.com/installs/INSTALLNAME/phpmyadmin)
    • Export DB from WP Engine as an SQL file
    • Create a DB on your local machine wp_INSTALLNAME
    • Import DB from the export you just did
  9. Configure your on you local environment
    • Rename a wp-config-sample.php file on you local environment to wp-confg.php
    • Change all necessary variables: DB_NAME , DB_USER, DB_HOST
      define('DB_NAME', 'DBNAME');
      
      /** MySQL database username */
      define('DB_USER', 'USER');
      
      /** MySQL database password */
      define('DB_PASSWORD', 'PASSWORD');
      
      /** MySQL hostname */
      define('DB_HOST', 'localhost');
    • Define WP_HOME and WP_SITEURL to whatever your local URL is
      define('WP_HOME',    'http://LOCALURL.DEV'); define('WP_SITEURL', 'http://LOCALURL.DEV');
  10. Install and activate any necessary plugins using WP-CLI
    $ wp plugin install PLUGINNAME --activate
  11. Push all changes to WP Engine via Git