Making Envoyer Play Nice With ServerPilot


I decided to give Envoyer a try the other day and found its set up process and documentation lacking - as I’m guessing you have - which is most likely why you’re reading this. :)

If you’re having difficulty setting up Envoyer with ServerPilot, read on.

Add Project

Sign up with Envoyer and click the big, red Add Project button to add your first project. A modal will open; fill in the necessary information and click save.

Click the big, red arrow button to continue.

Add a Server

Once you’ve added a project you’re ready to add a server. This is where the docs are lacking.

Click on the Servers tab, then click the Add Server button. Fill in the information, and under Connect As, enter your app username. Under Project Path, enter the path to your app directory, such as:

/srv/users/USERNAME/apps/APPNAME

Click the Save Server button and you’ll be presented with your Public SSH Key. Copy this key to your clipboard or store it in a file.

Close the modal.

Click the pencil icon to the right of your server name.

According to ServerPilot support: “No services, including PHP-FPM, should need to be restarted when deploying new code. Envoyer shouldn’t need to modify any server configurations or restart services.” So go ahead and uncheck Restart FPM After Deployments in the Deployments section.

Under the System section, enter php as the PHP Path (this is what works for me), and if you’re running PHP 7, enter composer7.0-sp as the Composer Path. Refer to How to Use Composer for PHP Dependency Management for your version of PHP.

Click Save Server.

SSH Into Your Server

SSH into your server as the app user, not the serverpilot user.

$ ssh APPUSER@server.IP.address

Add Public SSH Key

Add your Public SSH Key to .ssh/authorized_keys

$ nano .ssh/authorized_keys

Paste the key into the authorized_keys file, then save and close.

Envoyer puts each deployment inside a releases directory, which then has a symlink - named current - that points to the most recent deployment. Your web root on ServerPilot is named public, so in order for your app to serve files without modifying your nginx config you need to create your own symlink to Envoyer’s current symlink and name it public.

But first, you need to either delete the default public directory, or rename it.

Delete the public directory

rm apps/APPNAME/public/index.php
rmdir apps/APPNAME/public

Rename the public directory

mv apps/APPNAME/public apps/APPNAME/-public

Now add the symlink to the current directory…

$ ln -s current/public apps/APPNAME/public

Check Connection

To make sure your connection is working properly, head back to Envoyer and click the chasing arrows icon under Connection Status; if everything went according to plan the little circle will turn green.

That’s it! You’re now ready to deploy your app!