1010
1111安装phpldapadmin会同时安装php5.4以及httpd2.4.6
1212
13+ yum安装的phpldapadmin汉化文件在 ` /usr/share/phpldapadmin/locale/zh_CN/LC_MESSAGES ` 目录下
14+
15+ ![ iShot_2025-06-18_15.55.51] ( https://raw.githubusercontent.com/pptfz/picgo-images/master/img/iShot_2025-06-18_15.55.51.png )
16+
1317:::
1418
1519``` shell
@@ -312,15 +316,13 @@ mv mozillaOrgPerson.xml bak/
312316
313317
314318
315-
316-
317319## docker安装
318320
319321[ phpldapadmin github地址] ( https://github.com/osixia/docker-phpLDAPadmin )
320322
321323### ` osixia/phpldapadmin `
322324
323- 启动容器
325+ #### 启动容器
324326
325327:::tip 说明
326328
@@ -333,29 +335,261 @@ docker run \
333335 -d \
334336 -p 8081:80 \
335337 -v phpldapadmin:/container/service/phpldapadmin/assets/config \
336- --privileged \
337338 --name phpldapadmin \
338339 --hostname phpldapadmin \
339- --env PHPLDAPADMIN_HTTPS=false \
340- --env PHPLDAPADMIN_LDAP_HOSTS=10.0.8.4 \
340+ -e PHPLDAPADMIN_HTTPS=false \
341+ -e PHPLDAPADMIN_LDAP_HOSTS=10.0.0.102 \
341342 --restart=always \
342343 --detach \
343344 osixia/phpldapadmin:0.9.0
344345```
345346
346347
347348
348- 浏览器访问
349+ #### 浏览器访问
349350
350351` IP:端口 `
351352
352- ![ iShot_2022-09-09_22.16.56 ] ( https://raw.githubusercontent.com/pptfz/picgo-images/master/img/iShot_2022-09-09_22.16.56 .png )
353+ ![ iShot_2025-06-18_13.59.10 ] ( https://raw.githubusercontent.com/pptfz/picgo-images/master/img/iShot_2025-06-18_13.59.10 .png )
353354
354355
355356
356357登录后
357358
358- ![ iShot_2022-09-09_22.17.54] ( https://raw.githubusercontent.com/pptfz/picgo-images/master/img/iShot_2022-09-09_22.17.54.png )
359+ ![ iShot_2025-06-18_13.56.53] ( https://raw.githubusercontent.com/pptfz/picgo-images/master/img/iShot_2025-06-18_13.56.53.png )
360+
361+
362+
363+ #### 禁止匿名登录
364+
365+ 如果使用 [ bitnami] ( https://hub.docker.com/r/bitnami/openldap ) 镜像安装openldap,则需要在启动容器的时候添加环境变量 ` LDAP_ALLOW_ANON_BINDING=no ` 关闭匿名登录,这样在连接phpldapadmin的时候,虽然登录页面还是有 ` Anonymous ` 的按钮,但是点击登录提示是失败的
366+
367+ ![ iShot_2025-06-18_14.35.41] ( https://raw.githubusercontent.com/pptfz/picgo-images/master/img/iShot_2025-06-18_14.35.41.png )
368+
369+
370+
371+ #### 汉化
372+
373+ ##### 临时方法
374+
375+ [ osixia docker镜像] ( https://github.com/osixia/docker-phpLDAPadmin ) 安装后默认是英文的
376+
377+ 进入容器查看支持的语言,发现是没有中文的
378+
379+ ``` shell
380+ $ docker exec -it phpldapadmin bash
381+ $ locale -a
382+ C
383+ C.UTF-8
384+ en_US.utf8
385+ POSIX
386+ ```
387+
388+
389+
390+ 但是在 ` /var/www/phpldapadmin/locale/ ` 目录下是有多语言支持的
391+
392+ ``` shell
393+ $ ls -l /var/www/phpldapadmin/locale/
394+ total 0
395+ drwxr-xr-x 3 www-data www-data 25 Jun 18 08:11 ca_ES
396+ drwxr-xr-x 3 www-data www-data 25 Jun 18 08:11 cs_CZ
397+ drwxr-xr-x 3 www-data www-data 25 Jun 18 08:11 da_DK
398+ drwxr-xr-x 3 www-data www-data 25 Jun 18 08:11 de_DE
399+ drwxr-xr-x 3 www-data www-data 25 Jun 18 08:11 es_ES
400+ drwxr-xr-x 3 www-data www-data 25 Jun 18 08:11 fi_FI
401+ drwxr-xr-x 3 www-data www-data 25 Jun 18 08:11 fr_FR
402+ drwxr-xr-x 3 www-data www-data 25 Jun 18 08:11 gn_PY
403+ drwxr-xr-x 3 www-data www-data 25 Jun 18 08:11 hu_HU
404+ drwxr-xr-x 3 www-data www-data 25 Jun 18 08:11 it_IT
405+ drwxr-xr-x 3 www-data www-data 25 Jun 18 08:11 ja_JP
406+ drwxr-xr-x 3 www-data www-data 25 Jun 18 08:11 nb_NO
407+ drwxr-xr-x 3 www-data www-data 25 Jun 18 08:11 nl_BE
408+ drwxr-xr-x 3 www-data www-data 25 Jun 18 08:11 oc_FR
409+ drwxr-xr-x 3 www-data www-data 25 Jun 18 08:11 pl_PL
410+ drwxr-xr-x 3 www-data www-data 25 Jun 18 08:11 pt_BR
411+ drwxr-xr-x 3 www-data www-data 25 Jun 18 08:11 ru_RU
412+ drwxr-xr-x 3 www-data www-data 25 Jun 18 08:11 sk_SK
413+ drwxr-xr-x 3 www-data www-data 25 Jun 18 08:11 sv_FI
414+ drwxr-xr-x 3 www-data www-data 25 Jun 18 08:11 tr_TR
415+ drwxr-xr-x 3 www-data www-data 25 Jun 18 08:11 uk_UA
416+ drwxr-xr-x 3 www-data www-data 25 Jun 18 08:11 zh_CN
417+ drwxr-xr-x 3 www-data www-data 25 Jun 18 08:11 zh_TW
418+ ```
419+
420+
421+
422+ 查看 ` /etc/locale.gen ` 文件内容,默认生效的是英文
423+
424+ ``` shell
425+ $ egrep -v ' ^$|#' /etc/locale.gen
426+ en_US.UTF-8 UTF-8
427+ ```
428+
429+
430+
431+ 修改 ` /etc/locale.gen ` 文件,将注释的中文配置取消
432+
433+ ``` shell
434+ sed -i ' s/# zh_CN.UTF-8 UTF-8/zh_CN.UTF-8 UTF-8/' /etc/locale.gen
435+ ```
436+
437+
438+
439+ 再次查看 ` /etc/locale.gen ` 文件
440+
441+ ``` shell
442+ $ egrep -v ' ^$|#' /etc/locale.gen
443+ zh_CN.UTF-8 UTF-8
444+ en_US.UTF-8 UTF-8
445+ ```
446+
447+
448+
449+ 根据 ` /etc/locale.gen ` 中的配置,生成本地语言环境文件
450+
451+ ``` shell
452+ $ locale-gen
453+ Generating locales (this might take a while)...
454+ zh_CN.UTF-8... done
455+ en_US.UTF-8... done
456+ Generation complete.
457+ ```
458+
459+
460+
461+ 重启docker容器即可
462+
463+
464+
465+
466+
467+ ##### 永久方法
468+
469+ 临时方法是手动进入容器修改,但是如果删除容器后配置就失效了,因此永久方式就是依据官方 [ Dockerfile] ( https://github.com/osixia/docker-phpLDAPadmin/blob/stable/image/Dockerfile ) 制作一个新的镜像,
470+
471+
472+
473+ 克隆仓库
474+
475+ ``` shell
476+ git clone https://github.com/osixia/docker-phpLDAPadmin.git
477+ ```
478+
479+
480+
481+ 修改Dockerfile
482+
483+ :::tip 说明
484+
485+ 新增如下命令,把涉及到nginx的相关源配置全部删除,因为基础镜像引用到了nginx相关源,但是nginx相关源的GPG key 已经过期,因此会造成构建失败
486+
487+ ``` shell
488+ RUN sed -i ' /nginx.org/d' /etc/apt/sources.list /etc/apt/sources.list.d/* .list 2> /dev/null || true
489+ ```
490+
491+
492+
493+ 由于基础镜像nginx相关源GPG key 已经过期,构建失败报错如下
494+
495+ ``` shell
496+ W: GPG error: http://nginx.org/packages/mainline/debian buster InRelease: The following signatures were invalid: EXPKEYSIG ABF5BD827BD9BF62 nginx signing key < signing-key@nginx.com>
497+ E: The repository ' http://nginx.org/packages/mainline/debian buster InRelease' is not signed.
498+ ```
499+
500+
501+
502+ 在 ` apt-get update ` 后新增如下命令,使镜像默认语言环境为中文
503+
504+ ``` shell
505+ RUN apt-get update \
506+ && sed -i ' s/# zh_CN.UTF-8 UTF-8/zh_CN.UTF-8 UTF-8/' /etc/locale.gen \
507+ && locale-gen \
508+ ```
509+
510+ :::
511+
512+
513+
514+ ``` dockerfile
515+ cat > Dockerfile << EOF
516+ FROM osixia/web-baseimage:release-1.2.0-dev
517+
518+ # phpLDAPadmin version
519+ ARG PHPLDAPADMIN_VERSION=1.2.5
520+
521+ # Add multiple process stack to supervise apache2 and php7.3-fpm
522+ # sources: https://github.com/osixia/docker-light-baseimage/blob/stable/image/tool/add-multiple-process-stack
523+ # https://github.com/osixia/docker-light-baseimage/blob/stable/image/tool/add-service-available
524+ # https://github.com/osixia/docker-web-baseimage/blob/stable/image/service-available/:apache2/download.sh
525+ # https://github.com/osixia/docker-web-baseimage/blob/stable/image/service-available/:php7.3-fpm/download.sh
526+ # https://github.com/osixia/light-baseimage/blob/stable/image/service-available/:ssl-tools/download.sh
527+ # Install ca-certificates, curl and php dependencies
528+ # Download phpLDAPadmin, check file integrity, and unzip phpLDAPadmin to /var/www/phpldapadmin_bootstrap
529+ # Remove curl
530+ RUN sed -i '/nginx.org/d' /etc/apt/sources.list /etc/apt/sources.list.d/*.list 2>/dev/null || true
531+
532+ RUN apt-get update \
533+ && sed -i 's/# zh_CN.UTF-8 UTF-8/zh_CN.UTF-8 UTF-8/' /etc/locale.gen \
534+ && locale-gen \
535+ && /container/tool/add-multiple-process-stack \
536+ && /container/tool/add-service-available :apache2 :php7.3-fpm :ssl-tools \
537+ && LC_ALL=C DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
538+ ca-certificates \
539+ curl \
540+ php7.3-ldap \
541+ php7.3-readline \
542+ php7.3-xml \
543+ && curl -o phpldapadmin.tar.gz -SL https://github.com/leenooks/phpLDAPadmin/archive/${PHPLDAPADMIN_VERSION}.tar.gz \
544+ && mkdir -p /var/www/phpldapadmin_bootstrap /var/www/phpldapadmin \
545+ && tar -xzf phpldapadmin.tar.gz --strip 1 -C /var/www/phpldapadmin_bootstrap \
546+ && apt-get remove -y --purge --auto-remove curl ca-certificates \
547+ && rm phpldapadmin.tar.gz \
548+ && apt-get clean \
549+ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
550+
551+ # Add service directory to /container/service
552+ ADD service /container/service
553+
554+ # Use baseimage install-service script
555+ # https://github.com/osixia/docker-light-baseimage/blob/stable/image/tool/install-service
556+ RUN /container/tool/install-service
557+
558+ # Add default env variables
559+ ADD environment /container/environment/99-default
560+
561+ # Set phpLDAPadmin data directory in a data volume
562+ VOLUME ["/var/www/phpldapadmin" ]
563+
564+ # Expose http and https default ports
565+ EXPOSE 80 443
566+ EOF
567+ ```
568+
569+
570+
571+ 构建
572+
573+ 使用 ** Docker Buildx** 来构建跨平台镜像,否则本地 Docker 默认只支持你当前机器的架构
574+
575+ ```
576+ docker buildx create --use --name mybuilder
577+ docker buildx inspect mybuilder --bootstrap
578+ ```
579+
580+
581+
582+ 多平台构建必须加 ` --push ` 推送到远程仓库,否则生成的镜像不会显示在本地,单平台构建时可以用 ` --load ` 加载到本地
583+
584+ ``` shell
585+ docker buildx build --platform linux/amd64,linux/arm64 -t pptfz/phpldapadmin:1.2.5 . --push
586+ ```
587+
588+
589+
590+ 推送成功后就可以使用自己构建的镜像解决 ` osixia/phpldapadmin ` 默认语言为英文的问题了
591+
592+ ![ iShot_2025-06-19_11.09.44] ( https://raw.githubusercontent.com/pptfz/picgo-images/master/img/iShot_2025-06-19_11.09.44.png )
359593
360594
361595
0 commit comments