doutuan9357
2017-04-19 12:02
采纳率: 100%
浏览 80
已采纳

CloudFoundry容器安装linux邮件命令

While porting a PHP/Wordpress application to CloudFoundry, we are facing the issue that the application relies on the linux mail command, which is not installed on CloudFoundry containers by default.

Is there a way of getting this installed within the container the apps runs on upon startup?

图片转代码服务由CSDN问答提供 功能建议

在将PHP / Wordpress应用程序移植到CloudFoundry时,我们面临的问题是应用程序依赖于linux <代码 > mail 命令,默认情况下未安装在CloudFoundry容器上。

有没有办法在启动时运行应用程序的容器中安装这个?

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dreamfly0514 2017-04-20 11:58
    已采纳

    The best solution is to transition your app to talking directly to an SMTP server. There are Wordpress plugins that will let you do this. You might want to consider utilizing one of them. I don't know your situation, but using them is often straightforward.

    If that's not an option, you basically need to package a mail binary or script with your app. You can then either point Wordpress to that executable directly or you can adjust the PATH environment variable so the binary is on your path and Wordpress can find it.

    A couple notes on this:

    1. You can't install RPM or DEB packages because you can't get root access on CF. The best you can do is to bring your own binaries and scripts with the application (or write a custom build pack, but that's a lot more work).

    2. You might be able to take the mail binary from a Linux system and bundle it with your app. For example, install mail in a VM (running Ubuntu Trusty or use the cloudfoundry/cflinuxfs2 docker image), copy the mail binary and dependent shared libraries to a directory in your application. Push your app including those binaries. You can then adjust the PATH and LD_LIBRARY_PATH env variables so that Wordpress can find the command and the command can find it's associated shared libraries.

    3. If you can't / don't want to mess with #2, you could write a script in your favorite scripting language (Python, Perl, Ruby, PHP, etc..) that implements a similar cli as the mail command (just enough to satisfy the needs of Wordpress) and talks directly to an SMTP server. Name the script mail and point Wordpress to it or put in on the PATH.

    4. To adjust the PATH environment variable, you don't want to use cf set-env. That's because you can only override variables with cf set-env, you can't do the traditional PATH=$PATH:/my/new/path. To make this work, you want to include a .profile file in the root of your application. This will be picked up and sourced prior to your application starting and in it you can add PATH=$PATH:$HOME/path/to/mail/script, where /path/to/mail/script is the location of what you are bundling with your application and what you want available on the path. We prefix that with $HOME so that it points to our application.

      https://docs.cloudfoundry.org/devguide/deploy-apps/deploy-app.html#profile

    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题