13.5. Environment Variables
13.5.1. Introduction to Environment Variables
Environment variables are placeholders for values that are provided to a software program at runtime. They are particularly useful when the values are likely to be different from one host system to the next, or from one run to the next. Including these placeholders in applications makes the application code more portable and flexible. This flexibility is critical for writing applications that are easily deployed and scaled on OpenShift Enterprise.
A number of standardized environment variables are available for applications hosted on OpenShift Enterprise. These variables serve as placeholders for application names, commonly accessed directory names, user names, passwords, host names, IP addresses, and more. The specific environment variables that are available to a given application is determined by the cartridges that have been added to that application. For example, an application with PHP and MySQL has access to environment variables that expose the PHP path information, including the host, port, user name, and password necessary for connecting to the MySQL database.
There are two ways to view the environment variables for an application:
- Add an
export
statement to theApp_Name/.openshift/action_hooks/build
file, then rungit push
. The variables are listed in the Git output and start withremote: declare -x
. - Access the application with SSH and run the
env
command at the shell prompt.