问题
all my MySQL environment variables result in an empty string such as echo getenv('OPENSHIFT_MYSQL_DB_URL'); echo getenv('OPENSHIFT_MYSQL_DB_HOST');
however the others such as echo getenv('OPENSHIFT_APP_NAME'); echo getenv('OPENSHIFT_REPO_DIR');
work perfectlly fine. Any ideas what i am doing wrong?
回答1:
I had the same issue, and tried creating and recreating Applications multiple times without success
The solution was to use Git to push the code to Openshift (at least one time), if you only use sFTP to push the code, those variables will not be accessible
回答2:
You can just use the rhc app stop & rhc app start commands to restart your application and the environment variables will then be provided to your application. Make sure that you don't just use the rhc app restart command, as it doesn't not usually work, think of it as an apachectl stop/start vs apachectl reload.
来源:https://stackoverflow.com/questions/26831631/openshift-mysql-environment-variables-not-set