openshift environment variables

you can find out your openshift mysql host, openshift mysql user and openshift mysql password by looking at your openshift environment variables

  • $ ssh myopenshiftuser@myopenshiftdomain
  • $ env | grep OPENSHIFT
more information on environment variables

OpenShift provides several environment variables to reference for ease of use.

The following list are some common variables but far from exhaustive:

$_ENV[‘OPENSHIFT_APP_NAME’] – Application name
$_ENV[‘OPENSHIFT_GEAR_DIR’] – Application dir
$_ENV[‘OPENSHIFT_DATA_DIR’] – For persistent storage (between pushes)
$_ENV[‘OPENSHIFT_TMP_DIR’] – Temp storage (unmodified files deleted after 10 days)

When embedding a database using ‘rhc app cartridge add’, you can reference environment variables for username, host and password:

$_ENV[‘OPENSHIFT_DB_HOST’] – DB host
$_ENV[‘OPENSHIFT_DB_PORT’] – DB Port
$_ENV[‘OPENSHIFT_DB_USERNAME’] – DB Username
$_ENV[‘OPENSHIFT_DB_PASSWORD’] – DB Password

and you can use these in your drupal, wikkawiki, wordpress config file as follows


/** The name of the database for your lamp app */
define('DB_NAME', $_ENV['OPENSHIFT_APP_NAME']);
/** MySQL database username */
define('DB_USER', $_ENV['OPENSHIFT_DB_USERNAME']);
/** MySQL database password */
define('DB_PASSWORD', $_ENV['OPENSHIFT_DB_PASSWORD']);
/** MySQL hostname */
define('DB_HOST', $_ENV['OPENSHIFT_DB_HOST']);

Advertisements