I've created a php application on Openshift. Then I added a MySQL database to my app. Afterward I can see database related variables in SSH shell with env
command.
However when I tried to use environment varibles to setup db connection, it does not retrun them to my php code. As a example:
<?php
echo('App: '.$_ENV["OPENSHIFT_APP_NAME"].'<br/>');
echo('Host: '.$_ENV["OPENSHIFT_MYSQL_DB_HOST"]);
OPENSHIFT_APP_NAME
returns Application name correctly however OPENSHIFT_MYSQL_DB_HOST
is null and host information is not available.
I also restarted my application in console.
As a notice I used WinScp to directly upload my application and I'm not sure if deployment of php application needs anything more or less (like some require
stuff)?
Update:
When I checked phpMyAdmin codes, I saw it have a file 'conf.d/passenv.conf' with syntax like this:
PassEnv OPENSHIFT_MYSQL_DB_PORT
My be it help for resolving my problem.
You need to stop and start (NOT restart) your application, since you added MySQL after your application was created. use the rhc app stop and rhc app start commands.