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

佐手、 提交于 2019-12-04 12:56:19

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: []

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: []
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!