Are you trying to work out how to setup environment variables for your Digital Ocean droplet or app running on the app platform? Here’s how.

Digital Ocean droplet environment variables

Setting an environment variable for a droplet is a little more complicated than for an app running on the app platform.

Follow these steps to set environment variables on a Linux droplet:

  1. SSH into your droplet. If you’re not sure how to do that, see here
  2. Once connected, run the following command to set your environment variable:
1
export YOUR_VARIABLE_KEY=<your-variable-value>

App platform environment variables

To set environment variables for an app running on Digital Ocean’s app platform, follow these steps:

  1. Login to the Digital Ocean portal
  2. Open your app
  3. Click the “Settings” tab
  4. Scroll down until you see “App-Level Environment Variables”
  5. Click “Edit” and add the environment variable key and value
  6. Click “Save”

Your environment variable will now be available for your app.