如何使用配置文件(.ebextensions)在AWS Elastic Beanstalk上安装PHP IMAP Extension? [英] How to Install PHP IMAP Extension on AWS Elastic Beanstalk Using Configuration Files (.ebextensions)?

查看:181
本文介绍了如何使用配置文件(.ebextensions)在AWS Elastic Beanstalk上安装PHP IMAP Extension?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道如何使用配置文件(.ebextensions)在AWS Elastic Beanstalk上安装和启用PHP IMAP Extension吗?

Does anyone know how to install and enable PHP IMAP Extension on AWS Elastic Beanstalk using configuration files (.ebextensions)?

我正在使用运行PHP 7.0.16的64位Amazon Linux 2017.03 v2.4.0

I'm using 64bit Amazon Linux 2017.03 v2.4.0 running PHP 7.0.16

我尝试了以下几种方法:

I've tried several ways as follow:

第一种方法 我尝试在配置文件中使用files,但是它不起作用,在.ebextensions目录中的配置文件名是phpini.config,设置如下:

1st Way I've tried using files in configuration file but it doesn't work, the configuration filename is phpini.config in .ebextensions directory with below setup:

files:
  "/etc/php.d/phpimap.ini":
    mode: "000755"
    owner: root
    group: root
    content: |
      extension=imap.so

通过显示/etc/php-7.0.d/phpimap.ini解析为phpinfo()的其他.ini文件,但未安装IMAP.

The additional .ini files parsed into phpinfo() by displaying /etc/php-7.0.d/phpimap.ini but the IMAP won't installed.

第二种方式 使用container_command安装php-imap,但出现错误.

2nd Way Using container_command to install php-imap but i'm getting error.

container_commands:
  install_php_imap:
    command: yum install php55-imap

错误如下图所示:

第三种方式 使用组合的commands& files,只能成功安装 IMAP 和依赖项(常见于PHP),但不会激活 IMAP

3rd Way Using combined commands & files, it is only success installing IMAP and the dependencies (php common) but it doesn't activate the IMAP

a.通过添加以下脚本,在我的.ebextensions中创建installdependencies.config:

commands:
  install_phpcommon:
    test: '[ ! -f /etc/php.d/curl.ini ] && echo "php common not installed"'
    command:
      yum -y install https://archipelagointernational.s3.amazonaws.com/libs/php70w-common-7.0.16-1.w6.x86_64.rpm

b.通过添加以下脚本在我的.ebextensions中创建phpini.config:

commands:
  install_phpimap:
    test: '[ ! -f /etc/php.d/imap.ini ] && echo "php imap not installed"'
    command:
      yum -y install https://archipelagointernational.s3.amazonaws.com/libs/php70w-imap-7.0.16-1.w6.x86_64.rpm

files:
  "/etc/php.d/imap.ini":
    mode: "000755"
    owner: root
    group: root
    content: |
      extension=imap.so

第四种方法我正在通过将upload_max_filesizepost_max_sizeextension=imap.so添加到zzzphp.ini进行测试,并且仅包含两个值,即upload_max_filesizepost_max_size. extension=imap.so不包含在zzzphp.ini文件中.

4th Way I'm testing by adding upload_max_filesize, post_max_size and extension=imap.so to zzzphp.ini and only two values are included that are upload_max_filesize and post_max_size. The extension=imap.so not included into zzzphp.ini file.

下面是.ebextensions中的脚本phpini.config:

commands:
  install_phpimap:
    test: '[ ! -f /etc/php.d/imap.ini ] && echo "php imap not installed"'
    command:
      yum -y install https://archipelagointernational.s3.amazonaws.com/libs/php70w-imap-7.0.16-1.w6.x86_64.rpm

files:
  "/etc/php.d/zzzphp.ini":
    mode: "644"
    content: |
      upload_max_filesize = 50M
      post_max_size = 58M
      extension=imap.so

有什么建议吗?

谢谢.

推荐答案

终于可以了

在.ebextensions中创建两个文件,如下所示:

Create two files inside .ebextensions as follow:

installdependencies.config ,如果需要安装php common

installdependencies.config, install php common if it is required

commands:
  01_install_phpcommon:
    command:
      sudo yum -y install php70-common

phpini.config ,安装php imap并启用imap

phpini.config, install php imap and enable imap

commands:
  02_install_phpimap:
    command:
      sudo yum -y install php70-imap

files:
  "/etc/php.d/zzzphp.ini":
    mode: "644"
    content: |
      extension=imap.so

这篇关于如何使用配置文件(.ebextensions)在AWS Elastic Beanstalk上安装PHP IMAP Extension?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆