Statamic + Laravel Consulting

Expose on Forge


Recently Marcel Pociot released Expose, a pure PHP replacement for Ngrok.

One of its neat features is that you can set it up on your own server so you can control the domain. I wanted to play with this and get it up and running on my Forge server, however I ran into a few challenges, so I'm sharing in case others find it useful.

Before you start, make sure you read Expose's docs.

  1. Make sure the domain you want to use has wildcard DNS set up
    • i.e. An A record for *.yoursite.com
    • Note that Forge only supports a few DNS providers for wildcard certs
    • For me this meant I had to move a domain to Digital Ocean.
  2. In Forge, create a standard php site and enable wildcard domains
  3. ssh in an composer require beyondcode/expose
  4. Publish the config expose publish, this puts a .expose directory in /home/forge.
  5. Edit the configuration in /home/forge/.expose/config.php :
    • 'database' => '/home/forge/.expose/expose.db',
    • I’d recommend changing the admin user/password as well
  6. Link that config to ~, ln -s /home/forge/.expose/config.php /home/forge/.expose.php
  7. Create a daemon
    • Command: /home/forge/yoursite.com/vendor/bin/expose serve yoursite.com
    • Set the Directory to /home/forge

Locally, install Expose (composer global require beyondco/expose), then open the config (in ~/.expose/config.php) and set home to http://yoursite.com (note if you are serving this via SSL, change the port as well to 443).

To test, open Terminal, navigate to one of your locally served sites, and type expose. You could get something that looks like:

Congratulations, you're off and running!

© 2020 Silent Z Consulting