SiteHost

Environment Variables

Environment variables are user defined key-value pairs that can configure the behaviour of applications at runtime. Common ways they are used are for storing things like API keys, username/passwords, JVM runtime options, locale, etc.

You can use the commands env or printenv to check the environment variables set and if you are not happy with the variables set at the Container creation time you can update these variables at any time.

Adding Environment Variables

The steps to add new key-value pairs follows:

  1. When logged in to the SiteHost Control Panel, click the Containers module from the menu on the left.
  2. Click the Container Label from the list to open the Container management page.
  3. Click the Settings tab.
  4. Locate the form underneath the Environment Variables header.
  5. Fill in the Variable name and Variable contents as required.
  6. Hit the Save Variables button.

Removing Environment Variables

To remove environment variables, do the following:

  1. Once logged in to the SiteHost Control Panel, click the Containers module from the menu on the left.
  2. Click the Container Label from the list to open the Container management page.
  3. Click the Settings tab.
  4. Locate the form underneath the Environment Variables header.
  5. Locate the key-value pair you want to remove and put your mouse cursor over it. Click the red delete icon alongside the text fields to remove it.
  6. Hit the Save Variables button.

The container will be restarted for the environment variable changes to take effect.

Frequently Asked Questions

How do I get environment variables to work with the Silverstripe framework?

This is actually much easier than it sounds as Silverstripe already supports this out of the box. Simply add the environment variables Silverstripe is looking for through the SiteHost Control Panel, and the framework will take care of the rest.

This should be sufficient to get a simple Silverstripe site up and running:

The environment variables loaded here will have priority overy any included in the .env file, so there should no conflicts when setting this up. If you have all the variables Silverstripe needs here you can even do away with the .env file alltogether!