Alright, enough about that. If you’re here it’s most likely because you want to share your local development environment quickly and easily. Well, you have come to the right place. I wrote another article on how to use ngrok and Vagrant together– this is the same thing.. but more updated and includes a necessary step for using it with Varying Vagrant Vagrants (VVV).
Head over to the ngrok download page and download the Linux distribution. VVV is built using a Linux distro (Ubuntu) so we need the Linux version for it to work.
Download the zip and throw it in your VVV directory. For me, this was in ~/Sites/vvv/www/. We are putting it there so we know exactly where to find it when we vagrant ssh into VVV.
Serve up your local site!
Try visiting the ‘forwarding’ ngrok.io URL and you should see your site!
A big thank you to Doug Stewart for pointing me in the right direction when I asked for some insight into how to do this on Twitter!
You will probably run into issues with the URL being used by ngrok (WordPress stores some domain info in the database) so if you run into that you can try some plugins (like Root Relative URLs) that are made to make the domain WordPress expects more dynamic. Another method was pointed out by Doug in the comments here.
If you have any questions or run into problems, let me know in the comments!
This will (mostly) force WordPress to use the URLs of incoming traffic.
Doug’s comment was very helpful – although I found I had to use HTTP_X_ORIGINAL_HOST rather than HTTP_HOST.
Nice write up Zach, thanks. As another option for what Doug describes above, I use the plugin https://wordpress.org/plugins/dynamic-hostname/, which essentially does the same thing.
Thank you for this. You have no idea how hard I had to dig for this!
For me it was essential that I unzipped the file BEFORE SSHing into vagrant. I’m not sure why, but I think it was something about how permissions are set up on my local machine.