Environment Variables¶
For each website, the following environment variables are created by default:
WEBSITE_SERVER_NAME
: configured hostnamesWEBSITE_TYPE
: website typeWEBSITE_WEBROOT
: webroot locationFCGI_SOCKET_PATH
: path to the fcgi socket (only when PHP is enabled)PHP_VERSION
: selected PHP version, only when PHP is enabled)DB_HOST
: database hostname (only if there is a database)DB_NAME
: database name (only if there is a database)DB_USERNAME
: database username (only if there is a database)DB_PASSWORD
: database password (only if there is a database)
Custom Environment Variables¶
You can set or override environment variables per website, use the envvar
option in custom JSON:
{
"envvar": {
"MYENVVAR": "this is the value",
"DB_HOST": "override global DB_HOST variable here",
"http_proxy": "override global http_proxy variable here"
}
}
Warning
Variable names can only contain lower and uppercase letters [A-Za-z]
, numbers [0-9]
and underscores _
, also they cannot begin with a number.
Example Usage in PHP¶
$config = array(
'db_host' => $_SERVER['DB_HOST'],
'db_name' => $_SERVER['DB_NAME'],
'db_username' => $_SERVER['DB_USERNAME'],
'db_password' => $_SERVER['DB_PASSWORD'],
)