使用 Apache/FastCGI 访问 Catalyst Web 应用程序中的 shell 环境变量
我在 Amazon EC2 Linux 实例上有一个 Catalyst Web 应用程序,其内容由 Apache/FastCGI 提供服务。 每当我启动一个新实例时,我都需要获取数据库服务器的内部 IP,并通过在启动时运行以下命令将其分配给环境变量:
export MYSQL_HOST=$(dig +short ec2-*-*-*-*.compute-1.amazonaws.com);
我有一个 perl 模块,应该在查找 $MYSQL_HOST 环境后创建数据库连接变量值。
我的问题有很好的记录,因为 FastCGI 无法直接访问这些 shell 环境变量。
我看到您可以使用 Apache mod_env 中的 PassEnv 来访问环境变量,并且您可以使用 Apache 指令 FcgidInitialEnv 为 FastCGI 环境变量分配值(如果我在此处硬编码一个值,我可以使用 Perl 模块检索它) 。
我的 Apache 配置技能相当基础,所以我想知道是否有人可以推荐一种将这些技术结合在一起的方法,以便我的 perl 模块访问 $MYSQL_HOST。
谢谢!
I have a catalyst web application on an Amazon EC2 Linux instance and its content is being served by Apache/FastCGI.
Whenever I start a new instance, I need to get the internal IP of the database server and assign it to an environment variable by running this command at startup:
export MYSQL_HOST=$(dig +short ec2-*-*-*-*.compute-1.amazonaws.com);
I have a perl module that should create the database connection after looking up the $MYSQL_HOST environment variable value.
My problem is fairly well documented in that FastCGI cannot directly access these shell environment variables.
I see that you can use PassEnv from Apache mod_env to access environment variables and that you can assign values to FastCGI environment variables using the Apache directive, FcgidInitialEnv (if I hard-code a value in here, I can retrieve it using my Perl module).
My Apache configuration skills are rather basic so I was wondering if someone could recommend a way to tie these together in order for my perl module to access $MYSQL_HOST.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您尝试读取环境变量,请查看 $c->engine->env:
If you're trying to read environment variables, have a look at $c->engine->env: