How can I install the ioncube loader in the DDEV-Local web container?

2k Views Asked by At

I'm using DDEV to develop an OXID Esales Project. It's very comfortable to work with but now I have to install the Ioncube Loader. How can I do that? I have to put the .so file into the php direction inside the container and extend the php.ini. But I don't know how? Can someone help me?

Project: OXID E-Sales

  • php7.1
  • mysql5.7
  • MacOS
  • DDEV
3

There are 3 best solutions below

6
rfay On

[Note: This will never work on arm64 machines like the Mac M1, because ioncube provides only amd64/x86-64 binaries for their extension. If you need to bring something back to life from the past you can do it in the amd64 environment of gitpod.io for example.]

You could do this manually inside the web container each time you did a ddev start, but that doesn't sound like much fun.

Instead, we'll incorporate all the required changes into the add-on Dockerfile see docs.

Put these contents in your project's .ddev/web-build/Dockerfile and then it will (one time) build up your ddev-webserver image with the ioncube .so loader you need and the PHP configuration you need. This is for PHP 7.1 as you said, you'd change the PHP_VERSION for some other version.

ARG BASE_IMAGE
FROM $BASE_IMAGE

# Install the ioncube loader - set the PHP_VERSION to what you need
ENV PHP_VERSION=7.1
RUN mkdir -p /usr/local/lib && curl -sSlL  -o /tmp/ioncube.tar.gz https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz && tar -x --strip-components=1 -C /usr/local/lib -f /tmp/ioncube.tar.gz ioncube/ioncube_loader_lin_${PHP_VERSION}.so

# The ioncube_loader has to be the very first thing in the php.ini, so insert it there.
ENV PHP_INI_PATH=/etc/php/${PHP_VERSION}/fpm/php.ini
RUN (echo 'zend_extension = /usr/local/lib/ioncube_loader_lin_${PHP_VERSION}.so' && cat ${PHP_INI_PATH}) > ${PHP_INI_PATH}.new && mv ${PHP_INI_PATH}.new ${PHP_INI_PATH}
0
Sibin Grasic On

I released a ddev addon.

Will add ARM support asap :)

0
redphill On
  • add new .ddev/web-build/Dockerfile and adjust the PHP_VERSION variable to the target PHP version:
    ENV PHP_VERSION=7.4
    
    RUN bash -c ' \
        ARCH=$(uname -m); \
        if [[ $ARCH == arm* || $ARCH == aarch64 ]]; then \
            IONCUBE_LIB="https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_aarch64.tar.gz"; \
        else \
            IONCUBE_LIB="https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz"; \
        fi; \
        mkdir -p /usr/local/lib; \
        curl -sSlL -o /tmp/ioncube.tar.gz $IONCUBE_LIB; \
        tar -x --strip-components=1 -C /usr/local/lib -f /tmp/ioncube.tar.gz ioncube/ioncube_loader_lin_${PHP_VERSION}.so \
    '
    
    
    ENV PHP_INI_PATH=/etc/php/${PHP_VERSION}/fpm/php.ini
    RUN (echo 'zend_extension = /usr/local/lib/ioncube_loader_lin_${PHP_VERSION}.so' && cat ${PHP_INI_PATH}) > ${PHP_INI_PATH}.new && mv ${PHP_INI_PATH}.new ${PHP_INI_PATH}
    
    ENV PHP_INI_PATH=/etc/php/${PHP_VERSION}/cli/php.ini
    RUN (echo 'zend_extension = /usr/local/lib/ioncube_loader_lin_${PHP_VERSION}.so' && cat ${PHP_INI_PATH}) > ${PHP_INI_PATH}.new && mv ${PHP_INI_PATH}.new ${PHP_INI_PATH}