PHP configure not finding LDAP header libraries

I ran into this issue trying to get PHP extensions involved in a Docker container. Here is what I had to do:

  1. apt-get install libldb-dev libldap2-dev
  2. ln -s /usr/lib/x86_64-linux-gnu/libldap.so /usr/lib/libldap.so \ && ln -s /usr/lib/x86_64-linux-gnu/liblber.so /usr/lib/liblber.so

This worked for me perfectly.

Install LDAP libraries:

apt-get install libldb-dev

Create SO linker files:

updatedb --prunepaths=/mnt
cd /usr/lib

if [ ! -L liblber-2.4.so.2 ];
then
    ln -s "$(locate liblber-2.4.so.2)"
fi

if [ ! -L liblber-2.4.so.2.8.3 ];
then
    ln -s "$(locate liblber-2.4.so.2.8.3)"
fi

if [ ! -L liblber.so ];
then
    ln -s "$(locate liblber.so)"
fi

if [ ! -L libldap.so ];
then
    ln -s "$(locate libldap.so)"
fi

if [ ! -L libldap_r.so ];
then
    ln -s "$(locate libldap_r.so)"
fi

Configure PHP:

./configure --with-ldap=/usr


The cleanest way to do it, according to this comment in the issues of the official PHP Docker image, is using libldap2-dev (in Debian/Ubuntu) and calling configure with --with-libdir=lib/x86_64-linux-gnu.

Tags:

Linux

Php

Ldap