SlideShare a Scribd company logo
REMOTE CONTROL WORDPRESS
Automated Deployment with WP-CLI and Aliases
2
Agenda.
1. Introduction
2. Local Development with WP-CLI
3. SSH Intro and Configuration
4. WP-CLI and Aliases
5. Database Commands
6. Scripting Multiple Commands
7. Complete Script
8. Questions?
Introduction
Automated Deployment with WP-CLI and
Aliases
SENIOR SALES ENGINEER
WP ENGINE
@SPICECADET
Edmund Turbin
5
Understand the problem
Define success
Think creatively
Sometimes solutions are not apparent
Can involve 3rd Parties or combinations of technologies
How can I overcome a challenge?
Sales Engineering = Finding Solutions.
Staging/Dev/Production
6
Deploy DB Changes to Local Development Environment from Production/Staging/Dev server
What Challenge are we Overcoming?
Local Environment
7
Developing WordPress locally
Create Aliases to access WordPress remotely
Connecting to the remotes via SSH
Using WP-CLI commands to execute MySQL queries
Deploy DB Changes from Local Development to Production/Staging/Dev server
What’s Involved?
Local Development with
WP-CLI
9
Local Dev Stack - MAMP/WAMP
Virtual Machines
Docker - Containers
Local Server (running on your laptop)
Local dev solution from web host
Many ways to work locally
Developers generally choose what works for them
Local Development Approach
Local Development Virtual Machine Configuration
Local Development Tools.
10
https://github.com/Varying-Vagrant-
Vagrants/VVV
https://www.vagrantup.com/https://www.virtualbox.org
VirtualBox
Hypervisor.
11
Virtual Machine Manager (VMM)
Creates and runs Virtual Machines
Runs on a Host Machine
VMs are called Guest Machines
VirtualBox
Virtualization.
12
Multiple virtual machines can run at the same time
Guest operating systems can be different - Mac,
Windows, Linux, etc.
VMs can be pre-built with commonly used apps -
Apache, Nginx, email server
Save state - start/stop, freeze, back up, copy
Host
Local machine where virtual instances run
Hypervisor
Thin layer on host that allocates CPU, memory and resources to a virtual
instance
Virtual Machine.
13
HOST OS
HYPERVISOR
GUEST VM 1
APPS
OS
GUEST VM 2
APPS
OS
Vagrant
Vagrant.
14
Automation tool for building and managing VMs
Uses VirtualBox as a base
Uses a provisioning tool for automation
Automatically installs and configures software on the
VM
WP-CLI.
15
Access commonly functionality in WordPress from the
command line.
Do something quickly in WordPress without menu-
diving
Automate repetitive tasks
Bundle several tasks together to create repeatable
scripts
WordPress Command Line Interface
https://wp-cli.org/
Bourne-Again Shell
BASH - Shell Scripting.
16
Unix shell and scripting language
Released in 1989 as free software
Common on macOS, Linux, Windows 10, etc.
Can execute commands from text and from file - shell
script
Allows control structures and variables
https://en.wikipedia.org/wiki/Bash_(Unix_shell)
17
Built on Ubuntu 14.04 LTS (Trusty) base VM
Provisions the following software packages
VVV - What’s under the hood
Tools
DatabaseServer
SSH Intro and Configuration
19
VVV is seen as a separate instance
Even though the guest runs on the host machine, it
acts like a remote
SSH is required to access the command line of the
guest machine
Secure Shell
Why do we need SSH?
> SSH
20
Public Key Authentication
SSH Intro
> SSHRemote
Public Key
Client
Private Key
https://www.ssh.com/ssh/public-key-authentication
21
Remote connection between two systems
Secured by public/private key authentication
client has an encrypted private key
server has a public key
connection checks to make sure keys are valid
Replaces password authentication for quicker access
Secure Shell
SSH Intro
> SSH
22
secure connection over port 22
ssh user_name@hostname
add key to list of hosts
-i option will allow public/private key
authentication to be used
SSH Command.
> SSH
Secure Shell
23
Host your_site
HostName your_site@your_domain.com
User user_name
IdentityFile path_to_private_key
Basic SSH Config File.
24
vagrant ssh-config
Host your_site
HostName 127.0.0.1
 User vagrant
 Port 2200
 UserKnownHostsFile /dev/null
 StrictHostKeyChecking no
 PasswordAuthentication no
 IdentityFile /path_to_private_key
 IdentitiesOnly yes
 LogLevel FATAL
 ForwardAgent yes
Generate Vagrant SSH.
25
vagrant ssh-config
Host your_site
HostName 127.0.0.1
 User vagrant
 Port 2200
 UserKnownHostsFile /dev/null
 StrictHostKeyChecking no
 PasswordAuthentication no
 IdentityFile /path_to_private_key
 IdentitiesOnly yes
 LogLevel FATAL
 ForwardAgent yes
Port Number Can Change - Regenerate.
WP-CLI and Aliases
27
WP-CLI.
https://make.wordpress.org/cli/
28
Shortcuts that you register in a .yml file
Allow you to run commands against a remote
WordPress instance
Can be grouped together
Bypass remote login, change directories to get to a
WordPress install
WP-CLI Features which requires some quick config
WP-CLI Aliases
ALIASES
29
Lesser known feature of WP-CLI
Aliases can be globally set or on a site by site basis
What’s the benefit?
time saved
WP-CLI Features which requires some quick config
WP-CLI Aliases
ALIASES
30
@prod:
ssh: your_production_site
@dev:
ssh: your_development_site
path: /srv/www/edmund
@both:
- @prod
- @dev
wpcli.yml or config.yml
https://make.wordpress.org/cli/handbook/config/#config-files
ALIASES
31
/**
*
* WP-CLI commands that use Aliases
*
*/
wp cli info
wp @dev cli info
wp @prod cli info
Basic Commands with Aliases
ALIASES
Database Commands
33
# Get help and list of commands
wp help db
Basic DB Commands.
34
Basic DB Commands.
Scripting Multiple Commands
36
# check if a plugin is installed
wp @both plugin is-installed hello
# return value for last command - 0 = true
echo $?
# install plugin if $? false
if [ $? -eq 0 ]; then wp @prod plugin install hello ——
activate; fi
Simple Logical Plugin Example.
37
#! /bin/bash
# check if a plugin is installed
wp @dev plugin is-installed hello
# install plugin if $? false
if [ $? -eq 0 ]; then wp @dev plugin install hello ——activate;
fi
We Can Save Commands in a Script.
38
# create a variable and save a string
NAME=edmund
# Print the value of the variable
echo $NAME
edmund
We Can Save Values in a Variable.
39
# create a variable and save a string
BLOG_NAME=${wp option get blogname}
# Print the value of the variable
echo $BLOG_NAME
Edmund Turbin’s Blog
We Can Save Commands in Variables.
40
# Save command output as a variable
PROD_SITEURL=$(wp @prod option get siteurl);
DEV_SITEURL=$(wp @dev option get siteurl);	
Get URLs from dev and production.
41
# Get db from remote WP site and download it as a local
file
wp @prod db export - > prod.sql
- option prints to screen
> option redirects output to a local file
Export the WordPress DB.
42
# Import the downloaded .sql file
wp @dev db import /srv/www/edmund/prod.sql
Full path used to point to the .sql file
Import the WordPress DB on Dev.
43
# Search and replace siteurl option
wp @dev search-replace $prod_siteurl $dev_siteurl
Change production siteurl to dev.
44
# Delete the file
rm prod.sql
Cleanup.
45
# Chane permissions on our file
chmod +x getdb.sh
# Execute the script
./getdb.sh
Make the script executable and run it.
Complete Script
47
#!/bin/bash
	
#get siteurl option from prod and dev
PROD_SITEURL=$(wp @prod option get siteurl);
DEV_SITEURL=$(wp @dev option get siteurl);
	
#Export database from prod and import to dev
wp @prod db export - > prod.sql
wp @dev db import /srv/www/edmund/prod.sql
	
#Update siteurl
wp @dev search-replace $PROD_SITEURL $DEV_SITEURL
	
#Remove .sql file
rm prod.sql
Complete Script.
https://gist.github.com/spicecadet/71d65fab0480812bc66b09b69d056253
Conclusion
49
VVV for local development
WP-CLI & Aliases
Scripting can make a list of commands repeatable
Conclusion
50
https://torquemag.io/2018/11/using-the-command-line-for-
automation-part-i-remote-control-wordpress-with-wp-cli-
aliases/
torque.io Blog Post
51
SSH Documentation: https://www.ssh.com/ssh/
WP Migrate DB - https://wordpress.org/plugins/wp-migrate-db/
WP-CLI Command Reference: https://developer.wordpress.org/cli/commands/
Bash Script Tutorial: https://linuxconfig.org/bash-scripting-tutorial
Going Further - WP Local Docker: https://github.com/10up/wp-local-docker
References & Links
EDMUND.TURBIN@WPENGINE.COM
@SPICECADET
Thank you.
Edmund Turbin - Senior Sales Engineer

More Related Content

What's hot

12 Composer #burningkeyboards
12 Composer #burningkeyboards12 Composer #burningkeyboards
12 Composer #burningkeyboards
Denis Ristic
 
App development with quasar (pdf)
App development with quasar (pdf)App development with quasar (pdf)
App development with quasar (pdf)
wonyong hwang
 
eZ UnConference#2 - eZ Publish 5 basics Philippe Vincent-Royol & Florent Huck
eZ UnConference#2 - eZ Publish 5 basics Philippe Vincent-Royol & Florent HuckeZ UnConference#2 - eZ Publish 5 basics Philippe Vincent-Royol & Florent Huck
eZ UnConference#2 - eZ Publish 5 basics Philippe Vincent-Royol & Florent Huck
eZ Publish Community
 
Continuous Integration with Hackintosh
Continuous Integration with HackintoshContinuous Integration with Hackintosh
Continuous Integration with Hackintosh
David Ventura, M.E.T.
 
Pivotal Cloud Foundry
Pivotal Cloud FoundryPivotal Cloud Foundry
Pivotal Cloud Foundry
Sufyaan Kazi
 
DevOps: Docker Workshop
DevOps: Docker WorkshopDevOps: Docker Workshop
DevOps: Docker Workshop
Joonas Hämäläinen
 
Learnings from Real eZ Publish 5 Projects
Learnings from Real eZ Publish 5 ProjectsLearnings from Real eZ Publish 5 Projects
Learnings from Real eZ Publish 5 Projects
Donat Fritschy
 
Composer
ComposerComposer
Composer
Arshad Ali
 
Installing AtoM with Ansible
Installing AtoM with AnsibleInstalling AtoM with Ansible
Installing AtoM with Ansible
Artefactual Systems - AtoM
 
Deploying Windows Containers on Windows Server 2016
Deploying Windows Containers on Windows Server 2016Deploying Windows Containers on Windows Server 2016
Deploying Windows Containers on Windows Server 2016
Ben Hall
 
Ansible best practices
Ansible best practicesAnsible best practices
Ansible best practices
StephaneFlotat1
 
The How and Why of Windows containers
The How and Why of Windows containersThe How and Why of Windows containers
The How and Why of Windows containers
Ben Hall
 
DockerCon EU 2018 - Dockerfile Best Practices
DockerCon EU 2018 - Dockerfile Best PracticesDockerCon EU 2018 - Dockerfile Best Practices
DockerCon EU 2018 - Dockerfile Best Practices
Tibor Vass
 
Docker & rancher
Docker & rancherDocker & rancher
Docker & rancher
Alin Voinea
 
Ansible + WordPress
Ansible + WordPressAnsible + WordPress
Ansible + WordPress
Alan Lok
 
wp-cli
wp-cliwp-cli
Creating docker custom image
Creating docker custom imageCreating docker custom image
Creating docker custom image
t lc
 
Gradle + Google I/O 2014 remarks
Gradle + Google I/O 2014 remarksGradle + Google I/O 2014 remarks
Gradle + Google I/O 2014 remarks
Damian Mee
 
Running Docker in Development & Production (DevSum 2015)
Running Docker in Development & Production (DevSum 2015)Running Docker in Development & Production (DevSum 2015)
Running Docker in Development & Production (DevSum 2015)
Ben Hall
 

What's hot (19)

12 Composer #burningkeyboards
12 Composer #burningkeyboards12 Composer #burningkeyboards
12 Composer #burningkeyboards
 
App development with quasar (pdf)
App development with quasar (pdf)App development with quasar (pdf)
App development with quasar (pdf)
 
eZ UnConference#2 - eZ Publish 5 basics Philippe Vincent-Royol & Florent Huck
eZ UnConference#2 - eZ Publish 5 basics Philippe Vincent-Royol & Florent HuckeZ UnConference#2 - eZ Publish 5 basics Philippe Vincent-Royol & Florent Huck
eZ UnConference#2 - eZ Publish 5 basics Philippe Vincent-Royol & Florent Huck
 
Continuous Integration with Hackintosh
Continuous Integration with HackintoshContinuous Integration with Hackintosh
Continuous Integration with Hackintosh
 
Pivotal Cloud Foundry
Pivotal Cloud FoundryPivotal Cloud Foundry
Pivotal Cloud Foundry
 
DevOps: Docker Workshop
DevOps: Docker WorkshopDevOps: Docker Workshop
DevOps: Docker Workshop
 
Learnings from Real eZ Publish 5 Projects
Learnings from Real eZ Publish 5 ProjectsLearnings from Real eZ Publish 5 Projects
Learnings from Real eZ Publish 5 Projects
 
Composer
ComposerComposer
Composer
 
Installing AtoM with Ansible
Installing AtoM with AnsibleInstalling AtoM with Ansible
Installing AtoM with Ansible
 
Deploying Windows Containers on Windows Server 2016
Deploying Windows Containers on Windows Server 2016Deploying Windows Containers on Windows Server 2016
Deploying Windows Containers on Windows Server 2016
 
Ansible best practices
Ansible best practicesAnsible best practices
Ansible best practices
 
The How and Why of Windows containers
The How and Why of Windows containersThe How and Why of Windows containers
The How and Why of Windows containers
 
DockerCon EU 2018 - Dockerfile Best Practices
DockerCon EU 2018 - Dockerfile Best PracticesDockerCon EU 2018 - Dockerfile Best Practices
DockerCon EU 2018 - Dockerfile Best Practices
 
Docker & rancher
Docker & rancherDocker & rancher
Docker & rancher
 
Ansible + WordPress
Ansible + WordPressAnsible + WordPress
Ansible + WordPress
 
wp-cli
wp-cliwp-cli
wp-cli
 
Creating docker custom image
Creating docker custom imageCreating docker custom image
Creating docker custom image
 
Gradle + Google I/O 2014 remarks
Gradle + Google I/O 2014 remarksGradle + Google I/O 2014 remarks
Gradle + Google I/O 2014 remarks
 
Running Docker in Development & Production (DevSum 2015)
Running Docker in Development & Production (DevSum 2015)Running Docker in Development & Production (DevSum 2015)
Running Docker in Development & Production (DevSum 2015)
 

Similar to Remote Control WordPress

Introduction to WP-CLI: Manage WordPress from the command line
Introduction to WP-CLI: Manage WordPress from the command lineIntroduction to WP-CLI: Manage WordPress from the command line
Introduction to WP-CLI: Manage WordPress from the command line
Behzod Saidov
 
Advanced WordPress Tooling: By InstaWP.com
Advanced WordPress Tooling: By InstaWP.comAdvanced WordPress Tooling: By InstaWP.com
Advanced WordPress Tooling: By InstaWP.com
InstaWP Inc
 
WP-CLI Workshop at WordPress Meetup Cluj-Napoca
WP-CLI Workshop at WordPress Meetup Cluj-NapocaWP-CLI Workshop at WordPress Meetup Cluj-Napoca
WP-CLI Workshop at WordPress Meetup Cluj-Napoca
4nd4p0p
 
Power shell training
Power shell trainingPower shell training
Power shell training
David Brabant
 
Gestione avanzata di WordPress con WP-CLI - WordCamp Torino 2017 - Andrea Car...
Gestione avanzata di WordPress con WP-CLI - WordCamp Torino 2017 - Andrea Car...Gestione avanzata di WordPress con WP-CLI - WordCamp Torino 2017 - Andrea Car...
Gestione avanzata di WordPress con WP-CLI - WordCamp Torino 2017 - Andrea Car...
Andrea Cardinali
 
WP-CLI: WordCamp Nashville 2016
WP-CLI: WordCamp Nashville 2016WP-CLI: WordCamp Nashville 2016
WP-CLI: WordCamp Nashville 2016
Terell Moore
 
Deploying applications to Windows Server 2016 and Windows Containers
Deploying applications to Windows Server 2016 and Windows ContainersDeploying applications to Windows Server 2016 and Windows Containers
Deploying applications to Windows Server 2016 and Windows Containers
Ben Hall
 
Deploying .net core apps to Docker - dotnetConf Local Bengaluru
Deploying .net core apps to Docker - dotnetConf Local BengaluruDeploying .net core apps to Docker - dotnetConf Local Bengaluru
Deploying .net core apps to Docker - dotnetConf Local Bengaluru
Swaminathan Vetri
 
Automation day red hat ansible
   Automation day red hat ansible    Automation day red hat ansible
Automation day red hat ansible
Rodrigo Missiaggia
 
Word press, the automated way
Word press, the automated wayWord press, the automated way
Word press, the automated way
Michaël Perrin
 
Wordpress y Docker, de desarrollo a produccion
Wordpress y Docker, de desarrollo a produccionWordpress y Docker, de desarrollo a produccion
Wordpress y Docker, de desarrollo a produccion
Sysdig
 
Develop with docker 2014 aug
Develop with docker 2014 augDevelop with docker 2014 aug
Develop with docker 2014 aug
Vincent De Smet
 
Developers, Be a Bada$$ with WP-CLI
Developers, Be a Bada$$ with WP-CLIDevelopers, Be a Bada$$ with WP-CLI
Developers, Be a Bada$$ with WP-CLI
WP Engine
 
Docker for Web Developers: A Sneak Peek
Docker for Web Developers: A Sneak PeekDocker for Web Developers: A Sneak Peek
Docker for Web Developers: A Sneak Peek
msyukor
 
Lumen
LumenLumen
Session: WP Site Management using WP-CLI from Scratch
Session: WP Site Management using WP-CLI from ScratchSession: WP Site Management using WP-CLI from Scratch
Session: WP Site Management using WP-CLI from Scratch
Roald Umandal
 
Take Command of WordPress With WP-CLI
Take Command of WordPress With WP-CLITake Command of WordPress With WP-CLI
Take Command of WordPress With WP-CLI
Diana Thompson
 
[Codelab 2017] Docker 기초 및 활용 방안
[Codelab 2017] Docker 기초 및 활용 방안[Codelab 2017] Docker 기초 및 활용 방안
[Codelab 2017] Docker 기초 및 활용 방안
양재동 코드랩
 
Take Command of WordPress With WP-CLI
Take Command of WordPress With WP-CLITake Command of WordPress With WP-CLI
Take Command of WordPress With WP-CLI
Diana Thompson
 
Docker for developers on mac and windows
Docker for developers on mac and windowsDocker for developers on mac and windows
Docker for developers on mac and windows
Docker, Inc.
 

Similar to Remote Control WordPress (20)

Introduction to WP-CLI: Manage WordPress from the command line
Introduction to WP-CLI: Manage WordPress from the command lineIntroduction to WP-CLI: Manage WordPress from the command line
Introduction to WP-CLI: Manage WordPress from the command line
 
Advanced WordPress Tooling: By InstaWP.com
Advanced WordPress Tooling: By InstaWP.comAdvanced WordPress Tooling: By InstaWP.com
Advanced WordPress Tooling: By InstaWP.com
 
WP-CLI Workshop at WordPress Meetup Cluj-Napoca
WP-CLI Workshop at WordPress Meetup Cluj-NapocaWP-CLI Workshop at WordPress Meetup Cluj-Napoca
WP-CLI Workshop at WordPress Meetup Cluj-Napoca
 
Power shell training
Power shell trainingPower shell training
Power shell training
 
Gestione avanzata di WordPress con WP-CLI - WordCamp Torino 2017 - Andrea Car...
Gestione avanzata di WordPress con WP-CLI - WordCamp Torino 2017 - Andrea Car...Gestione avanzata di WordPress con WP-CLI - WordCamp Torino 2017 - Andrea Car...
Gestione avanzata di WordPress con WP-CLI - WordCamp Torino 2017 - Andrea Car...
 
WP-CLI: WordCamp Nashville 2016
WP-CLI: WordCamp Nashville 2016WP-CLI: WordCamp Nashville 2016
WP-CLI: WordCamp Nashville 2016
 
Deploying applications to Windows Server 2016 and Windows Containers
Deploying applications to Windows Server 2016 and Windows ContainersDeploying applications to Windows Server 2016 and Windows Containers
Deploying applications to Windows Server 2016 and Windows Containers
 
Deploying .net core apps to Docker - dotnetConf Local Bengaluru
Deploying .net core apps to Docker - dotnetConf Local BengaluruDeploying .net core apps to Docker - dotnetConf Local Bengaluru
Deploying .net core apps to Docker - dotnetConf Local Bengaluru
 
Automation day red hat ansible
   Automation day red hat ansible    Automation day red hat ansible
Automation day red hat ansible
 
Word press, the automated way
Word press, the automated wayWord press, the automated way
Word press, the automated way
 
Wordpress y Docker, de desarrollo a produccion
Wordpress y Docker, de desarrollo a produccionWordpress y Docker, de desarrollo a produccion
Wordpress y Docker, de desarrollo a produccion
 
Develop with docker 2014 aug
Develop with docker 2014 augDevelop with docker 2014 aug
Develop with docker 2014 aug
 
Developers, Be a Bada$$ with WP-CLI
Developers, Be a Bada$$ with WP-CLIDevelopers, Be a Bada$$ with WP-CLI
Developers, Be a Bada$$ with WP-CLI
 
Docker for Web Developers: A Sneak Peek
Docker for Web Developers: A Sneak PeekDocker for Web Developers: A Sneak Peek
Docker for Web Developers: A Sneak Peek
 
Lumen
LumenLumen
Lumen
 
Session: WP Site Management using WP-CLI from Scratch
Session: WP Site Management using WP-CLI from ScratchSession: WP Site Management using WP-CLI from Scratch
Session: WP Site Management using WP-CLI from Scratch
 
Take Command of WordPress With WP-CLI
Take Command of WordPress With WP-CLITake Command of WordPress With WP-CLI
Take Command of WordPress With WP-CLI
 
[Codelab 2017] Docker 기초 및 활용 방안
[Codelab 2017] Docker 기초 및 활용 방안[Codelab 2017] Docker 기초 및 활용 방안
[Codelab 2017] Docker 기초 및 활용 방안
 
Take Command of WordPress With WP-CLI
Take Command of WordPress With WP-CLITake Command of WordPress With WP-CLI
Take Command of WordPress With WP-CLI
 
Docker for developers on mac and windows
Docker for developers on mac and windowsDocker for developers on mac and windows
Docker for developers on mac and windows
 

More from Edmund Turbin

Production Ready WordPress #WPLDN
Production Ready WordPress #WPLDNProduction Ready WordPress #WPLDN
Production Ready WordPress #WPLDN
Edmund Turbin
 
Production Ready WordPress - WC Utrecht 2017
Production Ready WordPress  - WC Utrecht 2017Production Ready WordPress  - WC Utrecht 2017
Production Ready WordPress - WC Utrecht 2017
Edmund Turbin
 
Production ready word press
Production ready word pressProduction ready word press
Production ready word press
Edmund Turbin
 
The Themer's Guide to WP-CLI
The Themer's Guide to WP-CLIThe Themer's Guide to WP-CLI
The Themer's Guide to WP-CLI
Edmund Turbin
 
Configuration Management in WordPress
Configuration Management in WordPressConfiguration Management in WordPress
Configuration Management in WordPress
Edmund Turbin
 
The Themer's Guide to WP-CLI
The Themer's Guide to WP-CLIThe Themer's Guide to WP-CLI
The Themer's Guide to WP-CLI
Edmund Turbin
 
Customize it.
Customize it.Customize it.
Customize it.
Edmund Turbin
 
Theming in WordPress - Where do I Start?
Theming in WordPress - Where do I Start?Theming in WordPress - Where do I Start?
Theming in WordPress - Where do I Start?
Edmund Turbin
 
Word press gets responsive 4x3
Word press gets responsive 4x3Word press gets responsive 4x3
Word press gets responsive 4x3
Edmund Turbin
 
Scaling WooCommerce on WP Engine
Scaling WooCommerce on WP EngineScaling WooCommerce on WP Engine
Scaling WooCommerce on WP Engine
Edmund Turbin
 
Working in Harmony: Manchester - Optimize development and content workflows
Working in Harmony: Manchester - Optimize development and content workflowsWorking in Harmony: Manchester - Optimize development and content workflows
Working in Harmony: Manchester - Optimize development and content workflows
Edmund Turbin
 
Working in harmony
Working in harmonyWorking in harmony
Working in harmony
Edmund Turbin
 
Woo commerce scalability notes
Woo commerce scalability   notesWoo commerce scalability   notes
Woo commerce scalability notes
Edmund Turbin
 
Just For You - How to drive better engagement with localisation-based insights.
Just For You - How to drive better engagement with localisation-based insights.Just For You - How to drive better engagement with localisation-based insights.
Just For You - How to drive better engagement with localisation-based insights.
Edmund Turbin
 

More from Edmund Turbin (14)

Production Ready WordPress #WPLDN
Production Ready WordPress #WPLDNProduction Ready WordPress #WPLDN
Production Ready WordPress #WPLDN
 
Production Ready WordPress - WC Utrecht 2017
Production Ready WordPress  - WC Utrecht 2017Production Ready WordPress  - WC Utrecht 2017
Production Ready WordPress - WC Utrecht 2017
 
Production ready word press
Production ready word pressProduction ready word press
Production ready word press
 
The Themer's Guide to WP-CLI
The Themer's Guide to WP-CLIThe Themer's Guide to WP-CLI
The Themer's Guide to WP-CLI
 
Configuration Management in WordPress
Configuration Management in WordPressConfiguration Management in WordPress
Configuration Management in WordPress
 
The Themer's Guide to WP-CLI
The Themer's Guide to WP-CLIThe Themer's Guide to WP-CLI
The Themer's Guide to WP-CLI
 
Customize it.
Customize it.Customize it.
Customize it.
 
Theming in WordPress - Where do I Start?
Theming in WordPress - Where do I Start?Theming in WordPress - Where do I Start?
Theming in WordPress - Where do I Start?
 
Word press gets responsive 4x3
Word press gets responsive 4x3Word press gets responsive 4x3
Word press gets responsive 4x3
 
Scaling WooCommerce on WP Engine
Scaling WooCommerce on WP EngineScaling WooCommerce on WP Engine
Scaling WooCommerce on WP Engine
 
Working in Harmony: Manchester - Optimize development and content workflows
Working in Harmony: Manchester - Optimize development and content workflowsWorking in Harmony: Manchester - Optimize development and content workflows
Working in Harmony: Manchester - Optimize development and content workflows
 
Working in harmony
Working in harmonyWorking in harmony
Working in harmony
 
Woo commerce scalability notes
Woo commerce scalability   notesWoo commerce scalability   notes
Woo commerce scalability notes
 
Just For You - How to drive better engagement with localisation-based insights.
Just For You - How to drive better engagement with localisation-based insights.Just For You - How to drive better engagement with localisation-based insights.
Just For You - How to drive better engagement with localisation-based insights.
 

Recently uploaded

Applying Retrieval-Augmented Generation (RAG) to Combat Hallucinations in GenAI
Applying Retrieval-Augmented Generation (RAG) to Combat Hallucinations in GenAIApplying Retrieval-Augmented Generation (RAG) to Combat Hallucinations in GenAI
Applying Retrieval-Augmented Generation (RAG) to Combat Hallucinations in GenAI
ssuserd4e0d2
 
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-InTrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
TrustArc
 
Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...
Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...
Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...
Bert Blevins
 
WPRiders Company Presentation Slide Deck
WPRiders Company Presentation Slide DeckWPRiders Company Presentation Slide Deck
WPRiders Company Presentation Slide Deck
Lidia A.
 
Overview of Enterprise-scale landing zones using Cloud Adoption Framework Rea...
Overview of Enterprise-scale landing zones using Cloud Adoption Framework Rea...Overview of Enterprise-scale landing zones using Cloud Adoption Framework Rea...
Overview of Enterprise-scale landing zones using Cloud Adoption Framework Rea...
MarceloMiranda38200
 
“Deploying Large Language Models on a Raspberry Pi,” a Presentation from Usef...
“Deploying Large Language Models on a Raspberry Pi,” a Presentation from Usef...“Deploying Large Language Models on a Raspberry Pi,” a Presentation from Usef...
“Deploying Large Language Models on a Raspberry Pi,” a Presentation from Usef...
Edge AI and Vision Alliance
 
How Social Media Hackers Help You to See Your Wife's Message.pdf
How Social Media Hackers Help You to See Your Wife's Message.pdfHow Social Media Hackers Help You to See Your Wife's Message.pdf
How Social Media Hackers Help You to See Your Wife's Message.pdf
HackersList
 
find out more about the role of autonomous vehicles in facing global challenges
find out more about the role of autonomous vehicles in facing global challengesfind out more about the role of autonomous vehicles in facing global challenges
find out more about the role of autonomous vehicles in facing global challenges
huseindihon
 
ARTIFICIAL INTELLIGENCE (AI) IN MUSIC.pdf
ARTIFICIAL INTELLIGENCE (AI) IN MUSIC.pdfARTIFICIAL INTELLIGENCE (AI) IN MUSIC.pdf
ARTIFICIAL INTELLIGENCE (AI) IN MUSIC.pdf
Inglês no Mundo Digital
 
Dublin_mulesoft_meetup_Mulesoft_Salesforce_Integration (1).pptx
Dublin_mulesoft_meetup_Mulesoft_Salesforce_Integration (1).pptxDublin_mulesoft_meetup_Mulesoft_Salesforce_Integration (1).pptx
Dublin_mulesoft_meetup_Mulesoft_Salesforce_Integration (1).pptx
Kunal Gupta
 
IPLOOK Remote-Sensing Satellite Solution
IPLOOK Remote-Sensing Satellite SolutionIPLOOK Remote-Sensing Satellite Solution
IPLOOK Remote-Sensing Satellite Solution
IPLOOK Networks
 
Three New Criminal Laws in India 1 July 2024
Three New Criminal Laws in India 1 July 2024Three New Criminal Laws in India 1 July 2024
Three New Criminal Laws in India 1 July 2024
aakash malhotra
 
How to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptxHow to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptx
Adam Dunkels
 
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - MydbopsScaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Mydbops
 
Calgary MuleSoft Meetup APM and IDP .pptx
Calgary MuleSoft Meetup APM and IDP .pptxCalgary MuleSoft Meetup APM and IDP .pptx
Calgary MuleSoft Meetup APM and IDP .pptx
ishalveerrandhawa1
 
Best Practices for Effectively Running dbt in Airflow.pdf
Best Practices for Effectively Running dbt in Airflow.pdfBest Practices for Effectively Running dbt in Airflow.pdf
Best Practices for Effectively Running dbt in Airflow.pdf
Tatiana Al-Chueyr
 
Amul milk launches in US: Key details of its new products ...
Amul milk launches in US: Key details of its new products ...Amul milk launches in US: Key details of its new products ...
Amul milk launches in US: Key details of its new products ...
chetankumar9855
 
Salesforce AI & Einstein Copilot Workshop
Salesforce AI & Einstein Copilot WorkshopSalesforce AI & Einstein Copilot Workshop
Salesforce AI & Einstein Copilot Workshop
CEPTES Software Inc
 
Data Integration Basics: Merging & Joining Data
Data Integration Basics: Merging & Joining DataData Integration Basics: Merging & Joining Data
Data Integration Basics: Merging & Joining Data
Safe Software
 
Coordinate Systems in FME 101 - Webinar Slides
Coordinate Systems in FME 101 - Webinar SlidesCoordinate Systems in FME 101 - Webinar Slides
Coordinate Systems in FME 101 - Webinar Slides
Safe Software
 

Recently uploaded (20)

Applying Retrieval-Augmented Generation (RAG) to Combat Hallucinations in GenAI
Applying Retrieval-Augmented Generation (RAG) to Combat Hallucinations in GenAIApplying Retrieval-Augmented Generation (RAG) to Combat Hallucinations in GenAI
Applying Retrieval-Augmented Generation (RAG) to Combat Hallucinations in GenAI
 
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-InTrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
 
Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...
Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...
Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...
 
WPRiders Company Presentation Slide Deck
WPRiders Company Presentation Slide DeckWPRiders Company Presentation Slide Deck
WPRiders Company Presentation Slide Deck
 
Overview of Enterprise-scale landing zones using Cloud Adoption Framework Rea...
Overview of Enterprise-scale landing zones using Cloud Adoption Framework Rea...Overview of Enterprise-scale landing zones using Cloud Adoption Framework Rea...
Overview of Enterprise-scale landing zones using Cloud Adoption Framework Rea...
 
“Deploying Large Language Models on a Raspberry Pi,” a Presentation from Usef...
“Deploying Large Language Models on a Raspberry Pi,” a Presentation from Usef...“Deploying Large Language Models on a Raspberry Pi,” a Presentation from Usef...
“Deploying Large Language Models on a Raspberry Pi,” a Presentation from Usef...
 
How Social Media Hackers Help You to See Your Wife's Message.pdf
How Social Media Hackers Help You to See Your Wife's Message.pdfHow Social Media Hackers Help You to See Your Wife's Message.pdf
How Social Media Hackers Help You to See Your Wife's Message.pdf
 
find out more about the role of autonomous vehicles in facing global challenges
find out more about the role of autonomous vehicles in facing global challengesfind out more about the role of autonomous vehicles in facing global challenges
find out more about the role of autonomous vehicles in facing global challenges
 
ARTIFICIAL INTELLIGENCE (AI) IN MUSIC.pdf
ARTIFICIAL INTELLIGENCE (AI) IN MUSIC.pdfARTIFICIAL INTELLIGENCE (AI) IN MUSIC.pdf
ARTIFICIAL INTELLIGENCE (AI) IN MUSIC.pdf
 
Dublin_mulesoft_meetup_Mulesoft_Salesforce_Integration (1).pptx
Dublin_mulesoft_meetup_Mulesoft_Salesforce_Integration (1).pptxDublin_mulesoft_meetup_Mulesoft_Salesforce_Integration (1).pptx
Dublin_mulesoft_meetup_Mulesoft_Salesforce_Integration (1).pptx
 
IPLOOK Remote-Sensing Satellite Solution
IPLOOK Remote-Sensing Satellite SolutionIPLOOK Remote-Sensing Satellite Solution
IPLOOK Remote-Sensing Satellite Solution
 
Three New Criminal Laws in India 1 July 2024
Three New Criminal Laws in India 1 July 2024Three New Criminal Laws in India 1 July 2024
Three New Criminal Laws in India 1 July 2024
 
How to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptxHow to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptx
 
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - MydbopsScaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
 
Calgary MuleSoft Meetup APM and IDP .pptx
Calgary MuleSoft Meetup APM and IDP .pptxCalgary MuleSoft Meetup APM and IDP .pptx
Calgary MuleSoft Meetup APM and IDP .pptx
 
Best Practices for Effectively Running dbt in Airflow.pdf
Best Practices for Effectively Running dbt in Airflow.pdfBest Practices for Effectively Running dbt in Airflow.pdf
Best Practices for Effectively Running dbt in Airflow.pdf
 
Amul milk launches in US: Key details of its new products ...
Amul milk launches in US: Key details of its new products ...Amul milk launches in US: Key details of its new products ...
Amul milk launches in US: Key details of its new products ...
 
Salesforce AI & Einstein Copilot Workshop
Salesforce AI & Einstein Copilot WorkshopSalesforce AI & Einstein Copilot Workshop
Salesforce AI & Einstein Copilot Workshop
 
Data Integration Basics: Merging & Joining Data
Data Integration Basics: Merging & Joining DataData Integration Basics: Merging & Joining Data
Data Integration Basics: Merging & Joining Data
 
Coordinate Systems in FME 101 - Webinar Slides
Coordinate Systems in FME 101 - Webinar SlidesCoordinate Systems in FME 101 - Webinar Slides
Coordinate Systems in FME 101 - Webinar Slides
 

Remote Control WordPress

  • 1. REMOTE CONTROL WORDPRESS Automated Deployment with WP-CLI and Aliases
  • 2. 2 Agenda. 1. Introduction 2. Local Development with WP-CLI 3. SSH Intro and Configuration 4. WP-CLI and Aliases 5. Database Commands 6. Scripting Multiple Commands 7. Complete Script 8. Questions?
  • 4. Automated Deployment with WP-CLI and Aliases SENIOR SALES ENGINEER WP ENGINE @SPICECADET Edmund Turbin
  • 5. 5 Understand the problem Define success Think creatively Sometimes solutions are not apparent Can involve 3rd Parties or combinations of technologies How can I overcome a challenge? Sales Engineering = Finding Solutions.
  • 6. Staging/Dev/Production 6 Deploy DB Changes to Local Development Environment from Production/Staging/Dev server What Challenge are we Overcoming? Local Environment
  • 7. 7 Developing WordPress locally Create Aliases to access WordPress remotely Connecting to the remotes via SSH Using WP-CLI commands to execute MySQL queries Deploy DB Changes from Local Development to Production/Staging/Dev server What’s Involved?
  • 9. 9 Local Dev Stack - MAMP/WAMP Virtual Machines Docker - Containers Local Server (running on your laptop) Local dev solution from web host Many ways to work locally Developers generally choose what works for them Local Development Approach
  • 10. Local Development Virtual Machine Configuration Local Development Tools. 10 https://github.com/Varying-Vagrant- Vagrants/VVV https://www.vagrantup.com/https://www.virtualbox.org
  • 11. VirtualBox Hypervisor. 11 Virtual Machine Manager (VMM) Creates and runs Virtual Machines Runs on a Host Machine VMs are called Guest Machines
  • 12. VirtualBox Virtualization. 12 Multiple virtual machines can run at the same time Guest operating systems can be different - Mac, Windows, Linux, etc. VMs can be pre-built with commonly used apps - Apache, Nginx, email server Save state - start/stop, freeze, back up, copy
  • 13. Host Local machine where virtual instances run Hypervisor Thin layer on host that allocates CPU, memory and resources to a virtual instance Virtual Machine. 13 HOST OS HYPERVISOR GUEST VM 1 APPS OS GUEST VM 2 APPS OS
  • 14. Vagrant Vagrant. 14 Automation tool for building and managing VMs Uses VirtualBox as a base Uses a provisioning tool for automation Automatically installs and configures software on the VM
  • 15. WP-CLI. 15 Access commonly functionality in WordPress from the command line. Do something quickly in WordPress without menu- diving Automate repetitive tasks Bundle several tasks together to create repeatable scripts WordPress Command Line Interface https://wp-cli.org/
  • 16. Bourne-Again Shell BASH - Shell Scripting. 16 Unix shell and scripting language Released in 1989 as free software Common on macOS, Linux, Windows 10, etc. Can execute commands from text and from file - shell script Allows control structures and variables https://en.wikipedia.org/wiki/Bash_(Unix_shell)
  • 17. 17 Built on Ubuntu 14.04 LTS (Trusty) base VM Provisions the following software packages VVV - What’s under the hood Tools DatabaseServer
  • 18. SSH Intro and Configuration
  • 19. 19 VVV is seen as a separate instance Even though the guest runs on the host machine, it acts like a remote SSH is required to access the command line of the guest machine Secure Shell Why do we need SSH? > SSH
  • 20. 20 Public Key Authentication SSH Intro > SSHRemote Public Key Client Private Key https://www.ssh.com/ssh/public-key-authentication
  • 21. 21 Remote connection between two systems Secured by public/private key authentication client has an encrypted private key server has a public key connection checks to make sure keys are valid Replaces password authentication for quicker access Secure Shell SSH Intro > SSH
  • 22. 22 secure connection over port 22 ssh user_name@hostname add key to list of hosts -i option will allow public/private key authentication to be used SSH Command. > SSH Secure Shell
  • 23. 23 Host your_site HostName your_site@your_domain.com User user_name IdentityFile path_to_private_key Basic SSH Config File.
  • 24. 24 vagrant ssh-config Host your_site HostName 127.0.0.1  User vagrant  Port 2200  UserKnownHostsFile /dev/null  StrictHostKeyChecking no  PasswordAuthentication no  IdentityFile /path_to_private_key  IdentitiesOnly yes  LogLevel FATAL  ForwardAgent yes Generate Vagrant SSH.
  • 25. 25 vagrant ssh-config Host your_site HostName 127.0.0.1  User vagrant  Port 2200  UserKnownHostsFile /dev/null  StrictHostKeyChecking no  PasswordAuthentication no  IdentityFile /path_to_private_key  IdentitiesOnly yes  LogLevel FATAL  ForwardAgent yes Port Number Can Change - Regenerate.
  • 28. 28 Shortcuts that you register in a .yml file Allow you to run commands against a remote WordPress instance Can be grouped together Bypass remote login, change directories to get to a WordPress install WP-CLI Features which requires some quick config WP-CLI Aliases ALIASES
  • 29. 29 Lesser known feature of WP-CLI Aliases can be globally set or on a site by site basis What’s the benefit? time saved WP-CLI Features which requires some quick config WP-CLI Aliases ALIASES
  • 30. 30 @prod: ssh: your_production_site @dev: ssh: your_development_site path: /srv/www/edmund @both: - @prod - @dev wpcli.yml or config.yml https://make.wordpress.org/cli/handbook/config/#config-files ALIASES
  • 31. 31 /** * * WP-CLI commands that use Aliases * */ wp cli info wp @dev cli info wp @prod cli info Basic Commands with Aliases ALIASES
  • 33. 33 # Get help and list of commands wp help db Basic DB Commands.
  • 36. 36 # check if a plugin is installed wp @both plugin is-installed hello # return value for last command - 0 = true echo $? # install plugin if $? false if [ $? -eq 0 ]; then wp @prod plugin install hello —— activate; fi Simple Logical Plugin Example.
  • 37. 37 #! /bin/bash # check if a plugin is installed wp @dev plugin is-installed hello # install plugin if $? false if [ $? -eq 0 ]; then wp @dev plugin install hello ——activate; fi We Can Save Commands in a Script.
  • 38. 38 # create a variable and save a string NAME=edmund # Print the value of the variable echo $NAME edmund We Can Save Values in a Variable.
  • 39. 39 # create a variable and save a string BLOG_NAME=${wp option get blogname} # Print the value of the variable echo $BLOG_NAME Edmund Turbin’s Blog We Can Save Commands in Variables.
  • 40. 40 # Save command output as a variable PROD_SITEURL=$(wp @prod option get siteurl); DEV_SITEURL=$(wp @dev option get siteurl); Get URLs from dev and production.
  • 41. 41 # Get db from remote WP site and download it as a local file wp @prod db export - > prod.sql - option prints to screen > option redirects output to a local file Export the WordPress DB.
  • 42. 42 # Import the downloaded .sql file wp @dev db import /srv/www/edmund/prod.sql Full path used to point to the .sql file Import the WordPress DB on Dev.
  • 43. 43 # Search and replace siteurl option wp @dev search-replace $prod_siteurl $dev_siteurl Change production siteurl to dev.
  • 44. 44 # Delete the file rm prod.sql Cleanup.
  • 45. 45 # Chane permissions on our file chmod +x getdb.sh # Execute the script ./getdb.sh Make the script executable and run it.
  • 47. 47 #!/bin/bash #get siteurl option from prod and dev PROD_SITEURL=$(wp @prod option get siteurl); DEV_SITEURL=$(wp @dev option get siteurl); #Export database from prod and import to dev wp @prod db export - > prod.sql wp @dev db import /srv/www/edmund/prod.sql #Update siteurl wp @dev search-replace $PROD_SITEURL $DEV_SITEURL #Remove .sql file rm prod.sql Complete Script. https://gist.github.com/spicecadet/71d65fab0480812bc66b09b69d056253
  • 49. 49 VVV for local development WP-CLI & Aliases Scripting can make a list of commands repeatable Conclusion
  • 51. 51 SSH Documentation: https://www.ssh.com/ssh/ WP Migrate DB - https://wordpress.org/plugins/wp-migrate-db/ WP-CLI Command Reference: https://developer.wordpress.org/cli/commands/ Bash Script Tutorial: https://linuxconfig.org/bash-scripting-tutorial Going Further - WP Local Docker: https://github.com/10up/wp-local-docker References & Links