我意识到没有yum软件包mod_xsendfile (这是一个巨大的无赖),所以我想知道是否完全有可能通过.ebextensionsconfiguration添加它,因为它需要下载和编译。
是否甚至有可能完全用.ebextensionsconfiguration来做到这一点,或者我是否需要创build和维护一个自定义的AMI来使这个工作在Elastic Beanstalk上? 如果可能的话,如何在没有yum包的情况下configuration它?
除了你自己的答案:
除了httpd24-devel,你还需要安装gcc或apxs -cia mod_xsendfile.c将会失败。
谢天谢地,我设法只使用.ebextensionsconfiguration来.ebextensionsconfiguration。 我创build了以下configuration文件…
packages: yum: httpd24-devel: [] commands: xsendfile_download: command: wget https://tn123.org/mod_xsendfile/mod_xsendfile.c cwd: /home/ec2-user ignoreErrors: true xsendfile_install: command: apxs -cia mod_xsendfile.c cwd: /home/ec2-user ignoreErrors: true
首先 ,这确保了正确的httpd-devel版本与apxs一起安装,这是编译Apache扩展所必需的。
由于默认情况下, apxs不包含在Amazon的任何EB版本中,并且由于php 5.6的AMI包含Apache 2.4,所以我们必须确保我们使用特定的yum包来pipe理httpd24。
接下来 ,我们运行两个自定义命令: 第一个命令将 mod_xsendfile 下载到主目录(在Amazon Linux上始终为/home/ec2-user/ ),而第二个命令编译它。 由于每次创build实例时都会发生这种情况, mod_xsendfile在启动apache时, mod_xsendfile将始终可以使用。
事实certificate,这实际上是一个非常简单的解决scheme,它可以用来确保每次在AWS Elastic Beanstalk上创build新实例时,下载和编译任何Apache包。
注意:如果你想使这更容错(例如,如果mod_xsendfile链接在一个实例被启动的时候离线了),你可以把文件托pipe在别的地方,比如S3,然后从那里加载它。
但是这样做起作用,至less…没有自定义的AMI需要!