6. DATA AND WORDPRESS
• Core, plugin and theme files
• Data stored in a MySQL db
• Options/Transients/Object Caching
• Media Library assets and files
• Configuration wp-config.php
WHAT DATA DOES WORDPRESS USE?
8. DATA AND WORDPRESS
• Database
• Files
• Uploads
WHAT DATA IS NEEDED FOR DEPLOYMENT?
9. DATA AND WORDPRESS
• wp-config.php - keeps site specific configuration
• Different when using multiple dev environments
• Has sensitive information
CONFIGURATION
10. DATA AND WORDPRESS
• Some settings apply to all environments
• Each environment has unique settings
• Credentials will be different each environment
• Keep credentials out of version control
CONFIGURATION WITH MULTIPLE ENVIRONMENTS
11. DATA AND WORDPRESS
• Allows you to keep variations of your wp-config.php
• Each environment has it’s own unique config
• Uses variables to include proper configuration file
DOTENV
https://m.dotdev.co/secure-your-wordpress-config-with-dotenv-d939fcb06e24
14. DEPLOYMENT
• Version Control allows you to be sure that all changes are
pushed to environments
•Can ignore files and directories that are not needed
SYNC CODEBASE
16. DEPLOYMENT
• Typically not stored in version control
• Files can be large
• Will not change very much
UPLOADS DIRECTORY
17. DEPLOYMENT
• Copy all files
• Copy files you need
• Point to files on another server
SYNC UPLOADS METHODS
18. DEPLOYMENT
• FTP can be used to copy the entire uploads directory
• Can be done with client app
COPY ALL FILES
19. DEPLOYMENT
• rsync -avz --rsh=ssh user@host:/path/to/wp-content/uploads/* .
• Requires SSH some command line chops
• Not available on all hosting providers
COPY ALL FILES - RSYNC
20. DEPLOYMENT
• FTP can be used to copy only recent files
• WordPress organizes uploads by date if configured
COPY SOME FILES
27. DATABASE MIGRATION
• Allow you to run remote wp-cli commands
• Connects via SSH behind the scenes
• @dev, @stage, @production
• Uses a prefix before wp-cli command
• wp @dev cli info
WP-CLI ALIASES
28. DATABASE MIGRATION
• wp @production db export > production_db_export.sql
• wp @dev db reset —yes
•wp @dev db import production_db_export.sql
• wp @dev search-replace example.com example.dev
SYNC DATABASE ACROSS ENVIRONMENTS
https://gist.github.com/retlehs/aa47003249623e52b95a3fcd6f69b8fb#file-sync-prod-sh
30. CONFIGURATION MANAGEMENT
• Save time by transferring only what we need
• Less data to be transferred
• Data does not need to be synced
WHAT IF WE ONLY NEED TO MAKE A FEW CHANGES?
31. CONFIGURATION MANAGEMENT
• Settings are unique - site_url, home_url
• Not all plugins are needed on production
• Site admins or user can make settings changes
WHAT IF SETTINGS ARE DIFFERENT IN EACH ENVIRONMENT?
33. PLUGIN: WP-CFM
• Copy settings that you need, not entire DB
• Keep track of all settings in a single place
• Version Control
• Manage multiple environments
https://wordpress.org/plugins/wp-cfm/
BENEFITS
34. PLUGIN: WP-CFM
• Allows you to save options
• Can be saved as sets called Bundles
• Push changes to file
• Pull changes into database
https://wordpress.org/plugins/wp-cfm/
HOW DOES IT WORK?
35. PLUGIN: WP-CFM
• Data saved to disk as JSON array
• Can be committed to a repo
• Changes managed in WP Dashboard
• Permissions on settings?
https://wordpress.org/plugins/wp-cfm/
WORDPRESS CONFIGURATION MANAGEMENT
36. PLUGIN: WP-CFM
• WP settings (wp_options table)
• Multisite settings (wp_sitemeta table)
• Taxonomy terms
• Custom Field Suite field groups
https://wordpress.org/plugins/wp-cfm/
WHAT DATA CAN BE MANAGED?