可以openshift / rhcloud变量在.htaccess文件中使用 [英] Can openshift/rhcloud variables be used in an .htaccess file
问题描述
Openshift设置可使用几个环境变量
在这里看到(变量:OPENSHIFT_ *) HTTPS://developers.openshift。 COM / EN /管理 - 环境 - variables.html
有没有人使用这些变量在他们的.htaccess文件或者任何人都可以帮助这样做?
我使用专门适用于Mojolicious应用程序,因为得到它的工作在Openshift需要在.htaccess文件中的以下行。 [ID这里]指OPENSHIFT_APP_UUID值。我手动键入值出现了,而且从理论上讲,它不应该改变,但我想,以允许应用程序通过不同的用户进行部署,而无需他们寻找自己的ID和编辑.htaccess文件。
PerlSetVar psgi_app的/ var / lib中/ openshift / [ID这里] /app-root/runtime/repo/perl/index.pl
您可能是最好关闭用action_hook编写.htaccess文件后部署,并动态地包括环境变量所需的值,像这在你的.openshift / action_hooks / post_deploy
回声PassEnv $ {OPENSHIFT_REPO_DIR}>> $ {OPENSHIFT_REPO_DIR}的.htaccess
回声PerlSetVar psgi_app $ {OPENSHIFT_REPO_DIR}的Perl / index.pl>> $ {OPENSHIFT_REPO_DIR}的.htaccess
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
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
这篇关于可以openshift / rhcloud变量在.htaccess文件中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!