Arthur Attout
Arthur Attout

Reputation: 2916

How to enable LDAP on a dockerized Wordpress?

I have this container that I ran with a docker-compose.yml file.

version: '3'
services:

    db:
     <...>

    wordpress:
      depends_on:
        - db
      image: wordpress:latest
      ports:
        - "8000:80"
      restart: always
      environment:
        WORDPRESS_DB_HOST: db:3306
        WORDPRESS_DB_USER: wordpress
        WORDPRESS_DB_PASSWORD: wordpress

I need to enable LDAP on PHP but I really can't find out how to complete the steps explained in the tutorial.

You will need to use the --with-ldap[=DIR] configuration option when compiling PHP to enable LDAP support.

How am I supposed to do this on a running container ? Should this be done before running docker-compose up if so, which environment configuration am I supposed to use ?

Upvotes: 1

Views: 3125

Answers (1)

trust512
trust512

Reputation: 2256

You just have to use a different image as it's not easily configurable using the original image.

Have a look at dalareo/docker-wordpress-ldap-support on GitHub. You might use this Dockerfile by downloading it to the directory your project would be stored in and make a small change to your docker-compose.yml like here:

version: '3'
services:

    db:
     <...>

    wordpress:
      depends_on:
        - db
      # remove: image: wordpress:latest and put this instead:
      build: .
      # and place the rest of the definitions you normally have there

The Dockerfile copied from the repo:

FROM wordpress

RUN set -x \
    && apt-get update \
    && apt-get install -y libldap2-dev \
    && rm -rf /var/lib/apt/lists/* \
    && docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ \
    && docker-php-ext-install ldap \
    && apt-get purge -y --auto-remove libldap2-dev

edit

I've found a public registry image build from this Dockerfile

Now you don't actually have to make any changes to your original docker-compose.yml file except for changing the image your wordpress is expected to run from. From wordpress:latest to dalareo/wordpress-ldap

Upvotes: 3

Related Questions