# Environments

{% hint style="warning" %}
Please be sure of your agent type and version and pick the right documentation accordingly.
{% endhint %}

{% tabs %}
{% tab title="Node.js" %}
{% hint style="danger" %}
This is the documentation of the `forest-express-sequelize` and `forest-express-mongoose` Node.js agents that will soon reach end-of-support.

`forest-express-sequelize` v9 and `forest-express-mongoose` v9 are replaced by [`@forestadmin/agent`](https://docs.forestadmin.com/developer-guide-agents-nodejs/) v1.

Please check your agent type and version and read on or switch to the right documentation.
{% endhint %}
{% endtab %}

{% tab title="Ruby on Rails" %}
{% hint style="success" %}
This is still the latest Ruby on Rails documentation of the `forest_liana` agent, you’re at the right place, please read on.
{% endhint %}
{% endtab %}

{% tab title="Python" %}
{% hint style="danger" %}
This is the documentation of the `django-forestadmin` Django agent that will soon reach end-of-support.

If you’re using a Django agent, notice that `django-forestadmin` v1 is replaced by [`forestadmin-agent-django`](https://docs.forestadmin.com/developer-guide-agents-python) v1.

If you’re using a Flask agent, go to the [`forestadmin-agent-flask`](https://docs.forestadmin.com/developer-guide-agents-python) v1 documentation.

Please check your agent type and version and read on or switch to the right documentation.
{% endhint %}
{% endtab %}

{% tab title="PHP" %}
{% hint style="danger" %}
This is the documentation of the `forestadmin/laravel-forestadmin` Laravel agent that will soon reach end-of-support.

If you’re using a Laravel agent, notice that `forestadmin/laravel-forestadmin` v1 is replaced by [`forestadmin/laravel-forestadmin`](https://docs.forestadmin.com/developer-guide-agents-php) v3.

If you’re using a Symfony agent, go to the [`forestadmin/symfony-forestadmin`](https://docs.forestadmin.com/developer-guide-agents-php) v1 documentation.

Please check your agent type and version and read on or switch to the right documentation.
{% endhint %}
{% endtab %}
{% endtabs %}

## Environments

After you install for the first time, a local **development** environment is created for you, with a temporary `pre-deploy-to-production` branch (more on *branches* later).

Your first objective should be to deploy to **production**.

#### Deploying to Production

Forest Admin is meant to help you manage your operations: this can only happen if you work with your Production data! To do so, you need to **create your Production environment**.

Click "Deploy to production" on the top banner or in the *Environments* tab of your Project settings.

![](https://2014605362-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fx9GURwd0RAwi8uWZgH5v%2Fuploads%2Fgit-blob-f0f19930cb619163b9c1d51d0256cfda64691b43%2Fscreenshot%202020-02-21%20at%2015.52.52.png?alt=media)

**Deploy your admin backend**

On the first step, you need to input your admin backend's URL. This is the URL of the server onto which you have deployed (or will soon deploy) your admin backend's code base:

{% hint style="info" %}
If you need help deploying your admin backend's codebase, here are 2 step-by-step guides showing how it can be done [on Heroku](https://docs.forestadmin.com/documentation/extra-help/setup/deploy-to-production-on-heroku) or [on a standard ubuntu server](https://github.com/ForestAdmin/documentation/blob/main/reference-guide/how-it-works/broken-reference/README.md).
{% endhint %}

![](https://2014605362-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LR7SWfEwsNtj_ZiSkSA%2F-LxfCidvC6e2WyI-bQvG%2F-LxfFLqHv1IkqMdhcHDP%2Fimage.png?alt=media\&token=7256416b-267a-4641-8110-1099adc8c0d1)

{% hint style="warning" %}
Note that for **security reasons**, your admin backend must use the **HTTPS** protocol.
{% endhint %}

{% hint style="info" %}
The URL must not end with a trailing `/`.
{% endhint %}

**Connect to your database**

On the next step, you need to fill out your Production database credentials:

![](https://2014605362-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LR7SWfEwsNtj_ZiSkSA%2F-LxfCidvC6e2WyI-bQvG%2F-LxfFerHZHEsUbFysoVW%2Fimage.png?alt=media\&token=39dcb7d6-61fd-4b80-82fd-867fab6715e0)

{% hint style="info" %}
Your **database credentials** never leave your browser and are solely used to generate environment variables on the next step, so they are **never exposed**.
{% endhint %}

**Set your environment variables**

The final step requires that you add environment variables to your server. Follow on-screen instructions:

![](https://2014605362-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LR7SWfEwsNtj_ZiSkSA%2F-LxfCidvC6e2WyI-bQvG%2F-LxfFmCIPTAZVr14MvQf%2Fimage.png?alt=media\&token=e8f8aa42-f6fb-4ce2-a616-d5e1b7c01ef9)

Once your node server is successfully detected and running with the indicated environment variables, a "Finish" button will appear. Click on it to finalize the creation of your Production environment.

#### Creating a remote environment

Now that your admin panel is live in production, you might want to add an extra step for testing purposes. Forest Admin allows you to create remote (a.k.a **staging**) environments.

To create a new remote environment, go to your Project settings **(1)**:

![](https://2014605362-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fx9GURwd0RAwi8uWZgH5v%2Fuploads%2Fgit-blob-ebb3760e827bcac4044b09d59848fe3e75f4bd96%2Fscreenshot%202020-02-21%20at%2015.40.58.png?alt=media)

Then from the *Environments* tab, click on "Add a new environment" **(2)**.

![](https://2014605362-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LR7SWfEwsNtj_ZiSkSA%2F-MWTJu4CaTKvebWkM3eQ%2F-MWTONszTjn9cxDPdTM_%2Fimage.png?alt=media\&token=951f2e80-b0e8-4982-b2ff-0f9420b42ca9)

{% hint style="info" %}
You can choose to deploy to a remote (staging) environment **before** going to production (see below), it's up to you.
{% endhint %}

![](https://2014605362-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LR7SWfEwsNtj_ZiSkSA%2F-MWTJu4CaTKvebWkM3eQ%2F-MWTOUTC4GJNuQ2_0G9o%2Fimage.png?alt=media\&token=51e3a121-c4b6-41e8-91a6-3fce71659a1e)

**Choose your environment name**

You'll first be asked to input the name of the remote environment you wish to create:

![](https://2014605362-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LR7SWfEwsNtj_ZiSkSA%2F-MWTJu4CaTKvebWkM3eQ%2F-MWTOZqXqcLeSKYZJuRr%2Fimage.png?alt=media\&token=557bdc27-a985-4d85-b48e-6aeaff033aff)

**Enter your admin backend's URL for that environment**

Deploy your admin backend to your new server - your staging server for instance - then input its URL:

![](https://2014605362-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LR7SWfEwsNtj_ZiSkSA%2F-MWTJu4CaTKvebWkM3eQ%2F-MWTP23u_EPAPJLUUP0f%2Fimage.png?alt=media\&token=259e78c3-a765-4be1-aa39-ae79245c45af)

**Connect to your database**

You need a separate database for this new environment: if you're creating a *Staging*, then it must be your *staging* data, so your *staging* database!

![](https://2014605362-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LR7SWfEwsNtj_ZiSkSA%2F-MWTJu4CaTKvebWkM3eQ%2F-MWTP6_JUh1mm4XFVC9k%2Fimage.png?alt=media\&token=a2a97017-5068-4fdf-8d37-abc210dcbc8d)

{% hint style="info" %}
Your **database credentials** never leave your browser and are solely used to generate environment variables on the next step, so they are **never exposed**.
{% endhint %}

**Set your environment variables**

The final step requires that you add environment variables to your server. Follow on-screen instructions:

![](https://2014605362-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LR7SWfEwsNtj_ZiSkSA%2F-MWTJu4CaTKvebWkM3eQ%2F-MWTPC4cYaMXmRJbyRMl%2Fimage.png?alt=media\&token=f60a890b-9382-4dbb-bf8d-008cf04ce237)

Once your node server is successfully detected and running with the indicated environment variables, a **Finish** button will appear. Click on it to finalize the creation of your new remote environment.

#### Change environment origin

You can change the origins of your environments to create complex workflows - for instance dev > staging > preprod > production. All the layout of an environment will be generated based on its parent's layout.

To do so, click on the environment you wish to change the origin of and from its details page, select the desired origin in the *Set Origin* section.

![](https://2014605362-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fx9GURwd0RAwi8uWZgH5v%2Fuploads%2Fgit-blob-1bf80bc6201bc8f55cfb7816a3dcb63689b2d1b4%2Fenvironment-settings-details-set-origin.png?alt=media)

{% hint style="warning" %}
All child environment will be refreshed based on the new architectures.
{% endhint %}

#### Set an environment as production

A standard project usually has a production and at least a staging environment, but you may be using other remote environments. At some point you may feel the need to set another environment as your production environment (a.k.a reference).

{% hint style="info" %}
To set as production an environment it should have as origin the actual reference.
{% endhint %}

To do so, click on the environment you wish to set as production and from its details page, click "Set as production".

![](https://2014605362-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fx9GURwd0RAwi8uWZgH5v%2Fuploads%2Fgit-blob-80790eb60a7c443bf9d747c0d4a62600f29954d6%2Fscreenshot%202021-12-09%20at%2011.15.17.png?alt=media)

{% hint style="warning" %}
The actual reference will take the new production as origin. All children layout will be refreshed. Any layout change that is not applicable will be ignored.
{% endhint %}

#### Delete an environment

You may also delete an environment. **Be very careful** as there is no going back!
