Add ioncube to wordpress image

704 views Asked by At

I'm trying to serve multiple instances of

i have the following docker compose script to create a docker-WordPress container :

version: '3.7'
services:
  db:
    container_name: "${SITE_NAME}-db"
    image: mysql:latest
    env_file:
      - .env
    environment:
      MYSQL_DATABASE: ${DB_NAME}
      MYSQL_USER: ${DB_USER}
      MYSQL_PASSWORD: ${MYSQL_PASSWORD}
      MYSQL_RANDOM_ROOT_PASSWORD: ${ROOT_PASSWORD}
    ports:
      - "3306"
    volumes:
      - './db:/var/lib/mysql'
    restart: always
    networks:
      - lan
  site:
    container_name: "${SITE_NAME}-web"
    image: wordpress:latest
    environment:
      WORDPRESS_DEBUG: 0
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_USER: ${DB_USER}
      WORDPRESS_DB_PASSWORD: ${MYSQL_PASSWORD}
      WORDPRESS_DB_NAME: ${DB_NAME}
      WORDPRESS_CONFIG_EXTRA: |
        define('AUTOMATIC_UPDATER_DISABLED', true);
      VIRTUAL_HOST: ${SITE_DOMAIN},www.${SITE_DOMAIN}
      LETSENCRYPT_HOST: ${SITE_DOMAIN},www.${SITE_DOMAIN}
    volumes:
      - './wordpress:/var/www/html/wp-content'
      - './upload.ini:/usr/local/etc/php/conf.d/uploads.ini'
    restart: always
    depends_on:
      - db
    networks:
      - lan
      - net
volumes:
  db:
  wordpress:
  upload.ini:

networks:
  lan:
    internal: true
  net:
    external: true

On instance of a website requires for one of it's plugins the installation of ioncube

I cant seem to make it work. Is there a way to add ioncube ?

2

There are 2 answers

2
Bernhard Zürn On

Perhaps it makes sense to Use a custom Docker Image for your Wordpress instance. You can create one based on the wordpress image you already use and than add ioncube to it for example like this:

https://github.com/atsu666/docker-ioncube/blob/master/Dockerfile#L43

0
S.Bokesa On

In your php.Dockerfile add the following to install ioncube to the php image

    # Install curl
RUN apk --no-cache add curl


# Install IonCube Loader
# Create the IonCube directory
RUN mkdir -p /ioncube

# Download and extract IonCube Loader
RUN curl -o /ioncube/ioncube.tar.gz https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz \
    && tar xvzf /ioncube/ioncube.tar.gz -C /ioncube \
    && rm /ioncube/ioncube.tar.gz

COPY ioncube/ioncube_loader_lin_7.4.so /ioncube/ioncube_loader_lin_7.4.so

# Update the php.ini file with the Zend extension
RUN echo "zend_extension=/ioncube/ioncube_loader_lin_7.4.so" >> /usr/local/etc/php/php.ini  

Then make sure your server is connected to the php image from up stream in nginx config it looks as follow:

    location ~ \.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass php;
        }

You can confirm ioncube loader has been installed by running a shell command from php container like follow:

docker exec-it <name-of php container> /bin/sh

Then run the php -m command and it should output

[Zend Modules] Zend OPcache the ionCube PHP Loader + ionCube24

An you should also see the ionCube loader in the list of modules.

Remember to replace ioncube_loader_lin_7.x.so" with the version of your php. If you are running php 8.1 use ioncube_loader_lin_8.1.so"

For better results try to have a copy of the ioncube folder containg the file ioncube_loader_lin_8.1.so and also try to run the loader wizard file that comes with ioncube on the browser like:

http://localhost/loader-wizard.php if running on localhost to confirm installation.