Using Trellis to Provision and Deploy to DigitalOcean Droplets

DigitalOcean is a cloud infrastructure provider that offers virtual servers called droplets starting at $5/month that can handle most normal WordPress sites when provisioned with Trellis.

To provision a server, Trellis requires a server running a bare/stock version of Ubuntu 18.04 LTS (Bionic Beaver). When logged into DigitalOcean, create a new droplet and select the Ubuntu 18.04 option.

Screenshot of create droplets area in DigitalOcean

ℹ️ If you signup for DigitalOcean through our referral link you will receive a free $100 in credit for 2 months!

While creating a droplet you have the option to include SSH keys that are attached to your DigitalOcean account. Make sure your SSH key is included here so that the Ansible can connect to the droplet during provisioning.

You should already have installed Trellis locally and configured your WordPress site. Make sure to go ahead and enable SSL/Let’s Encrypt if you’re going to be using it. Let’s Encrypt integration requires that the canonical hosts for your sites ( and by default) to have DNS that points to your new droplet.

You should also make sure that you’ve updated group_vars/all/users.yml to include your SSH keys as described in the docs.

You might also want to setup a floating IP from the Networking area in DigitalOcean. This will allow you to create new droplets and switch them over to your static floating IP address without any downtime.

Screenshot of floating IPs area in DigitalOcean

Edit hosts/production and replace your_server_hostname with the floating IP address you assigned to your new droplet.



Provisioning DigitalOcean droplet

At this point you can now provision your new droplet. From your Trellis directory:

$ ansible-playbook server.yml -e env=production

When you see the following message, enter yes to continue:

TASK [connection : Check whether Ansible can connect as root] **********************************************************
The authenticity of host ' (' can't be established.
ED25519 key fingerprint is SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.
Are you sure you want to continue connecting (yes/no)?

The remote server playbook will run and provision your droplet with PHP 7.3, Nginx, and everything else included in Trellis.

Deploying to DigitalOcean droplet

Once your server is provisioned you’ll want to perform the first deploy. If you try to visit your site before deploying you’ll see a server 500 error. From your Trellis directory:

./bin/ production

After the first deploy is done, you can now either install WordPress by visiting the site or even import an existing database.

$5 droplet performance

If you enable the FastCGI caching in Trellis then you’ll be able to squeeze quite a bit of performance out of a $5 DigitalOcean droplet.

View on

Start the discussion on Roots Discourse

Join over 7,000 subscribers on our newsletter to get the latest Roots updates, along with occasional tips on building better WordPress sites.

Looking for WordPress plugin recommendations, the newest modern WordPress projects, and general web development tips and articles?

“Easily the best WordPress email I get.” Colin OBrien

Follow us on Twitter @rootswp

Ready to checkout?