如何在 Docker php-fpm alpine 中安装 LDAP
How to install LDAP in Docker php-fpm alpine
知道如何在 docker 文件
中安装 php Ldap 扩展
FROM php:7.2-fpm-alpine
我尝试了以下方法
RUN docker-php-ext-configure ldap --prefix=/usr/local/php --with-ldap=/usr/lib/i386-linux-gnu
RUN docker-php-ext-install ldap
但是当我构建 docker 时,我收到错误消息
configure: error: Cannot find ldap.h
ERROR: Service 'php' failed to build: The command '/bin/sh -c docker-php-ext-install ldap' returned a non-zero code: 1
PS:它是高山所以 'apt-get' 不会在这里工作,而是 'apk add'
您可以尝试 ldb-dev alpine package.`
FROM php:7.2-fpm-alpine
RUN apk add --no-cache ldb-dev
如果您遇到配置:错误:找不到ldap.h
尝试在基于 Alpine 的 Dockerfile
中添加这一行
RUN apk add ldb-dev libldap openldap-dev
这对我有用:
FROM php:7.4.9-fpm-alpine3.12
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/bin/
# Install PHP extensions
RUN install-php-extensions ldap
已使用以下 dockerfile 修复:
FROM php:7.2-fpm-alpine
# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# lumen packages
RUN apk add openldap-back-mdb
RUN apk add --update --virtual .build-deps autoconf g++ make zlib-dev curl-dev libidn2-dev libevent-dev icu-dev libidn-dev openldap libxml2-dev
RUN docker-php-ext-install intl soap
RUN docker-php-ext-install mbstring tokenizer mysqli pdo_mysql json hash iconv
RUN apk --update --no-cache add php7-ldap libldap php-ldap openldap-clients openldap openldap-back-mdb
RUN apk add --no-cache ldb-dev
RUN 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
#RUN docker-php-ext-configure ldap --prefix=/usr/local/php --with-ldap=/usr/lib/libldap.so
#RUN docker-php-ext-install ldap
ARG DOCKER_PHP_ENABLE_LDAP
RUN echo -n "With ldap support: " ; if [[ "${DOCKER_PHP_ENABLE_LDAP}" = "on" ]] ; then echo "Yes"; else echo "No" ; fi && \
if [ -z ${DOCKER_USER_UID+x} ]; then echo "DOCKER_USER_UID is unset"; DOCKER_USER_UID=1000; else echo "DOCKER_USER_UID is set to '$DOCKER_USER_UID'"; fi && \
if [ -z ${DOCKER_USER_GID+x} ]; then echo "DOCKER_USER_GID is unset"; DOCKER_USER_GID=1000; else echo "DOCKER_USER_GID is set to '$DOCKER_USER_GID'"; fi
# Enable LDAP
RUN if [ "${DOCKER_PHP_ENABLE_LDAP}" != "off" ]; then \
# Dependancy for ldap \
apk add --update --no-cache \
libldap && \
# Build dependancy for ldap \
apk add --update --no-cache --virtual .docker-php-ldap-dependancies \
openldap-dev && \
docker-php-ext-configure ldap && \
docker-php-ext-install ldap && \
apk del .docker-php-ldap-dependancies && \
php -m; \
else \
echo "Skip ldap support"; \
fi
RUN pecl install raphf propro
RUN docker-php-ext-enable raphf propro
RUN pecl install pecl_http
RUN echo -e "extension=raphf.so\nextension=propro.so\nextension=iconv.so\nextension=http.so" > /usr/local/etc/php/conf.d/docker-php-ext-http.ini
RUN rm -rf /usr/local/etc/php/conf.d/docker-php-ext-raphf.ini
RUN rm -rf /usr/local/etc/php/conf.d/docker-php-ext-propro.ini
RUN rm -rf /tmp/*
COPY ./app /var/www/html/
RUN chown -R www-data:www-data /var/www/html/
RUN chmod -R 755 /var/www/html/
WORKDIR /var/www/html/
RUN composer install
您需要使用 openldap-dev 来获得 ldap.h 文件以使用 docker-php-ext-install 脚本安装 ldap。
像这样的东西有效:
FROM php:8.0.2-fpm-alpine
RUN apk update \
&& apk add --no-cache --virtual .build-dependencies-in-virtual-world openldap-dev \
&& docker-php-ext-install ldap \
&& docker-php-ext-enable ldap \
&& apk del .build-dependencies-in-virtual-world
对我来说,我使用了我的 Laravel 项目:
My Dockerfile for a Laravel app
我不得不使用第 5 行,因为如果我不这样做,id 会得到这个:
未定义常量“LdapRecord\Models\Attributes\LDAP_ESCAPE_FILTER”
知道如何在 docker 文件
中安装 php Ldap 扩展FROM php:7.2-fpm-alpine
我尝试了以下方法
RUN docker-php-ext-configure ldap --prefix=/usr/local/php --with-ldap=/usr/lib/i386-linux-gnu
RUN docker-php-ext-install ldap
但是当我构建 docker 时,我收到错误消息
configure: error: Cannot find ldap.h
ERROR: Service 'php' failed to build: The command '/bin/sh -c docker-php-ext-install ldap' returned a non-zero code: 1
PS:它是高山所以 'apt-get' 不会在这里工作,而是 'apk add'
您可以尝试 ldb-dev alpine package.`
FROM php:7.2-fpm-alpine
RUN apk add --no-cache ldb-dev
如果您遇到配置:错误:找不到ldap.h 尝试在基于 Alpine 的 Dockerfile
中添加这一行RUN apk add ldb-dev libldap openldap-dev
这对我有用:
FROM php:7.4.9-fpm-alpine3.12
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/bin/
# Install PHP extensions
RUN install-php-extensions ldap
已使用以下 dockerfile 修复:
FROM php:7.2-fpm-alpine
# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# lumen packages
RUN apk add openldap-back-mdb
RUN apk add --update --virtual .build-deps autoconf g++ make zlib-dev curl-dev libidn2-dev libevent-dev icu-dev libidn-dev openldap libxml2-dev
RUN docker-php-ext-install intl soap
RUN docker-php-ext-install mbstring tokenizer mysqli pdo_mysql json hash iconv
RUN apk --update --no-cache add php7-ldap libldap php-ldap openldap-clients openldap openldap-back-mdb
RUN apk add --no-cache ldb-dev
RUN 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
#RUN docker-php-ext-configure ldap --prefix=/usr/local/php --with-ldap=/usr/lib/libldap.so
#RUN docker-php-ext-install ldap
ARG DOCKER_PHP_ENABLE_LDAP
RUN echo -n "With ldap support: " ; if [[ "${DOCKER_PHP_ENABLE_LDAP}" = "on" ]] ; then echo "Yes"; else echo "No" ; fi && \
if [ -z ${DOCKER_USER_UID+x} ]; then echo "DOCKER_USER_UID is unset"; DOCKER_USER_UID=1000; else echo "DOCKER_USER_UID is set to '$DOCKER_USER_UID'"; fi && \
if [ -z ${DOCKER_USER_GID+x} ]; then echo "DOCKER_USER_GID is unset"; DOCKER_USER_GID=1000; else echo "DOCKER_USER_GID is set to '$DOCKER_USER_GID'"; fi
# Enable LDAP
RUN if [ "${DOCKER_PHP_ENABLE_LDAP}" != "off" ]; then \
# Dependancy for ldap \
apk add --update --no-cache \
libldap && \
# Build dependancy for ldap \
apk add --update --no-cache --virtual .docker-php-ldap-dependancies \
openldap-dev && \
docker-php-ext-configure ldap && \
docker-php-ext-install ldap && \
apk del .docker-php-ldap-dependancies && \
php -m; \
else \
echo "Skip ldap support"; \
fi
RUN pecl install raphf propro
RUN docker-php-ext-enable raphf propro
RUN pecl install pecl_http
RUN echo -e "extension=raphf.so\nextension=propro.so\nextension=iconv.so\nextension=http.so" > /usr/local/etc/php/conf.d/docker-php-ext-http.ini
RUN rm -rf /usr/local/etc/php/conf.d/docker-php-ext-raphf.ini
RUN rm -rf /usr/local/etc/php/conf.d/docker-php-ext-propro.ini
RUN rm -rf /tmp/*
COPY ./app /var/www/html/
RUN chown -R www-data:www-data /var/www/html/
RUN chmod -R 755 /var/www/html/
WORKDIR /var/www/html/
RUN composer install
您需要使用 openldap-dev 来获得 ldap.h 文件以使用 docker-php-ext-install 脚本安装 ldap。
像这样的东西有效:
FROM php:8.0.2-fpm-alpine
RUN apk update \
&& apk add --no-cache --virtual .build-dependencies-in-virtual-world openldap-dev \
&& docker-php-ext-install ldap \
&& docker-php-ext-enable ldap \
&& apk del .build-dependencies-in-virtual-world
对我来说,我使用了我的 Laravel 项目: My Dockerfile for a Laravel app
我不得不使用第 5 行,因为如果我不这样做,id 会得到这个:
未定义常量“LdapRecord\Models\Attributes\LDAP_ESCAPE_FILTER”