Skip to content

Instantly share code, notes, and snippets.

@skwid138
Last active June 23, 2020 15:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skwid138/491ff1f184bae116bda5c021cf91f762 to your computer and use it in GitHub Desktop.
Save skwid138/491ff1f184bae116bda5c021cf91f762 to your computer and use it in GitHub Desktop.
WordPress local development with ngrok.

WordPress Local Development and ngrok (macOS)

Setup

  • Install ngrok with hombrew brew cask install ngrok
  • Run ngrok for your local site ngrok http -host-header=my.site.local 80
  • Copy the https url that appears in the terminal and use it below to replace the ngrok.io url
  • If using the standard WP setup add the following to the bottom of wp-config.php
<?php
// Add a value if using NGROK
$ngrok_url = 'https://your-tunnel.ngrok.io';

// Make sure to override the DB settings
if (isset($ngrok_url)) {
	define('WP_HOME', $ngrok_url);
	define('WP_SITEURL', $ngrok_url);
}
  • If using Root's Bedrock structure add the following to .env and comment out the existig WP_HOME definition
WP_HOME=https://your-tunnel.ngrok.io

Using a YAML config

  • Create a YMAL file to store your various local sites for ngrok touch ~/.ngrok2/ngrok.yml
  • Open the file inthe editor of your choice and add the following
tunnels:
  site1: # The name used to reference the site
    proto: http
    addr: 80
    host_header: my.site.local
  site1_443: # if your vhost is setup to use 443 this should also work
    proto: http
    addr: https://my.site.local:443
    host_header: my.site.local
  • Create the tunnel ngrok start site1
  • Follow the instructions from above to add the https url to your WordPress config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment