If you build WordPress sites, chances are you either know about VVV or are using it. If not, go ahead and get it set up! It is (in my opinion) the best way to handle local site development. Forget MAMP- the future is now.
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.
Unzip it in VVV
Now, SSH into your VVV install by
cd‘ing to the directory it is and running:
Next let’s go to where we put the zip:
Finally we can unzip it:
unzip ngrok.zip (it won’t be called exactly that, mine had the specific ngrok version added to the name)
Authenticate with ngrok
If you don’t have one, sign up real quick (free account is fine) and use version 2.0. Run the authtoken command to link your account with your local environment:
ngrok authtoken TOKEN_HERE
Serve up your local site!
Now, you should be able to serve up your site. Try running the following command:
ngrok http 80 -host-header=whatever_your_local_site_is.dev
By specifying -host-header we are telling ngrok which VVV site we want to serve. If that worked, your terminal should show something like this:
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!