问题
Openshift sets several environment variables that can be used.
See here (variables: OPENSHIFT_*) https://developers.openshift.com/en/managing-environment-variables.html
Has anyone used these variables in their .htaccess file or can anyone assist in doing so?
My use specifically applies to a Mojolicious app as getting it to work on Openshift requires the following line in the .htaccess file. [ID HERE] refers to the OPENSHIFT_APP_UUID value. I manually type the value there now, and in theory, it should not change but I'd like to allow the app to be deployed by different users without needing them to look for their ID and edit the .htaccess file.
PerlSetVar psgi_app /var/lib/openshift/[ID HERE]/app-root/runtime/repo/perl/index.pl
回答1:
You might be best off using an action_hook to write that .htaccess file post deploy and have it dynamically include the values of the environment variables that you want, something like this in your .openshift/action_hooks/post_deploy
echo "PassEnv ${OPENSHIFT_REPO_DIR}" >> ${OPENSHIFT_REPO_DIR}.htaccess
echo "PerlSetVar psgi_app ${OPENSHIFT_REPO_DIR}perl/index.pl" >> ${OPENSHIFT_REPO_DIR}.htaccess
来源:https://stackoverflow.com/questions/29402464/can-openshift-rhcloud-variables-be-used-in-an-htaccess-file