# Craft CMS environment variables

Source: https://docs.fortrabbit.com/guides/craft-cms/env-vars
Published: 2026-10-23
Updated: 2026-10-23
Reviewed: 2026-10-23

> The ENV vars Craft CMS needs on fortrabbit: database connection, environment name, security key and table prefix.


## ENV vars from the template

The Craft CMS [software template](/platform/concepts/software-templates) sets these [ENV vars](/platform/settings/env-vars) when the app is created. The `.env` file stays local: Craft's `.gitignore` keeps it out of the repository.



```apache
CRAFT_ENVIRONMENT=${FORTRABBIT_ENVIRONMENT_NAME}
CRAFT_DEV_MODE=false
CRAFT_ALLOW_ADMIN_CHANGES=false
CRAFT_ALLOW_UPDATES=false
CRAFT_SECURITY_KEY=…
CRAFT_STREAM_LOG=true
CRAFT_DB_DRIVER=mysql
CRAFT_DB_SERVER=${FORTRABBIT_DB_HOST}
CRAFT_DB_DSN=mysql:host=${FORTRABBIT_DB_HOST};port=3306;dbname=${FORTRABBIT_DB_NAME}
CRAFT_DB_USER=${FORTRABBIT_DB_USER}
CRAFT_DB_PASSWORD=${FORTRABBIT_DB_PASSWORD}
```

The `${FORTRABBIT_…}` values are [platform variables](/platform/settings/env-vars) that fortrabbit fills in. An app created without the Craft CMS template, or with deleted ENV vars, needs them added by hand:

} / {{app-env-name}}" path="/environments/{{app-env-id}}/env-vars"}

## Multi-environment configuration

`CRAFT_ENVIRONMENT` holds the name of the fortrabbit environment, for example `production`. Craft config files can group settings by that name, and the local `.env` sets its own:



```shell
CRAFT_ENVIRONMENT=dev
```

See the Craft docs on [configuration](https://craftcms.com/docs/5.x/configure.html) for the multi-environment config syntax.

## Table prefix

A local installation with a table prefix needs the same prefix on fortrabbit. Add it to the local `.env` and to the ENV vars of the environment:



```shell
CRAFT_DB_TABLE_PREFIX=craft_
```
