skip to Main Content

I’m pretty sure the zip extension was included by default in the amazon managed php elb image.

The usual way to do this was adding a config file like this to .ebextensions

packages:
    yum:
        php-zip70: []

However that doesn’t work anymore.

Any ideas?

2

Answers


  1. Chosen as BEST ANSWER

    This seemed to work for me as of 08/17/23

    Add a config file like this to .ebextensions

    EDIT Seems like the install commands can only be ran 1 time, otherwise there will be an error that kills the eb deploy because the module is already installed. Working on a more robust solution

    files:
      "/etc/php.d/98_zip.ini":
        mode: "000644"
        owner: root
        group: root
        content: |
          extension=zip.so
    commands:
      01_remove_old_config:
        command: "rm -f /etc/php.d/98_zip.ini.bak"
      02_install_stuff:
        command: "dnf -y install libzip libzip-devel"
      03_install_more_stuff:
        command: "pecl install zip"
    

  2. @asdfasdfsdfga gave some good hints. A more modern approach:

    Add the file .platform/hooks/prebuild/install-php-zip.sh

    #!/usr/bin/env bash
    
    yum -y install libzip libzip-devel
    
    # Will enable zip extension in /etc/php.ini
    pecl upgrade zip 
    

    Note that "pecl install zip" will return an error code if already installed (?!), resulting in your deployment failing the second time you attempt to deploy. Instead, use upgrade, which will install if not already installed, and complete successfully if already installed.

    The pecl command will insert ‘extension="zip.so"’ at the top of /etc/php.ini.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search