How to Install PHP IMAP Extension on AWS Elastic B

2020-07-17 04:34发布

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: error 2nd way

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.

enter image description here enter image description here

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.

5条回答
狗以群分
2楼-- · 2020-07-17 05:01

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: []
查看更多
SAY GOODBYE
3楼-- · 2020-07-17 05:02

This works for me, using ebextensions too (I'm running a container with PHP 7.2, it should work for your environment, replace accordly):

packages:
    yum:
        php72-imap: []
查看更多
何必那么认真
4楼-- · 2020-07-17 05:04

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.

查看更多
爱情/是我丢掉的垃圾
5楼-- · 2020-07-17 05:05

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
查看更多
叼着烟拽天下
6楼-- · 2020-07-17 05:22

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
查看更多
登录 后发表回答