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:
- Have WP Engine account and your ssh public key added to your account.
- Get our special
.gitignore
file that ignores WP core, because WP engine, - Have WP-CLI working on your machine
- http://wp-cli.org because you will use it for installing core and adding plugins to your local environment
Setup step by step:
- Navigate to folder where you are setting up you local environment
$ cd ~/..wordpress../my_wp_install_name
- Clone Production from WP Engine
$ git clone --recursive [email protected]:production/INSTALLNAME.git .
- Set up your Stage as remote.
$ git remote add INSTALLNAME-stage git@git.wpengine.com:staging/INSTALLNAME.git
- Fetch remote Stage
$ git fetch INSTALLNAME-stage
- 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
- Push
.gitignore
to WP Engine repository from here https://gist.github.com/lehelmatyus/7ca04af6be50c8f48dfb81dd8c5913e4 - Install local instance of WordPress using WP-CLI
$ wp core download
- 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
- 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
andWP_SITEURL
to whatever your local URL isdefine('WP_HOME', 'http://LOCALURL.DEV');
define('WP_SITEURL', 'http://LOCALURL.DEV');
- Install and activate any necessary plugins using WP-CLI
$ wp plugin install
PLUGINNAME
--activate
- Push all changes to WP Engine via Git