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.
  • Production environment is locked until the launch of the website

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.
  • Your client can directly add content to WP while you are developing on PROD

How:

You will set up WP engine production environment on your local environment, and you will push to it directly to Prod skipping Stage. You will set up Stage as a Remote so once 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 [email protected]: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 Code and DB from WP Engine
    • Create a backup of the current WP Engine Environment and download it
    • From the backup copy the content plugins folder into your local environments plugins folder
    • Remove the mu-plugins folder if you copied that as well
    • In the backup inside the wp-content folder there should be an SQL file. Set up your local DB from that SQL dump.
    • Alternatively you could get the DB like this
      • 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