简体   繁体   中英

How to Install PHP IMAP Extension on AWS Elastic Beanstalk Using Configuration Files (.ebextensions)?

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

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

I've tried several ways as follow:

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

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

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

container_commands:
  install_php_imap:
    command: yum install php55-imap

Error as image below: 错误第二种方式

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. Create installdependencies.config in my .ebextensions by adding bellow script:

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. Create phpini.config in my .ebextensions by adding bellow script:

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

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.

在此输入图像描述 在此输入图像描述

Below are the script phpini.config in .ebextensions :

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

Any suggestions?

Thanks in advance.

Finally it's work

Create two files inside .ebextensions as follow:

installdependencies.config , install php common if it is required

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

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

For me, below code in phpini.config solved the issue. Please notice the folder names as per php version. My php version is 7.2 hence below code works:

commands:
  install_phpimap:
    test: '[ ! -f /etc/php-7.2.d/imap.ini ] && echo "php imap not installed"'
    command:
      sudo yum -y install php72-imap

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

You're including the php-imap extension in php's configuration file, but that's not sufficient to install it.

You're going to have to pass something to your EBS provisioning method of choice telling it to install php-imap (or whatever it's called in that environment) at the system level.

I followed all of the suggestions here but my commands kept on failing because my composer required imap support and the container commands are run after... Here's what worked for me:

packages:
    yum:
        php72-imap.x86_64: []

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM