php - Php can't find tidy
问题描述
I am using a php7
in docker container
to run a service based on phpdocx library. It needs tidy
and some other extensions installed and active to work. I have installed php-tidy
however I am getting following warning.
PHP Warning: PHP Startup: Unable to load dynamic library 'tidy' (tried: /usr/lib/php7/modules/tidy (Error loading shared library /usr/lib/php7/modules/tidy: No such file or directory), /usr/lib/php7/modules/tidy.so (Error relocating /usr/lib/php7/modules/tidy.so: _zval_ptr_dtor: symbol not found)) in Unknown on line 0
Dockerfile
FROM php:7.3.2-cli-alpine3.9
USER root
COPY . code
WORKDIR code
RUN apk update && apk add php-tidy && apk add php-zip && apk add php-curl && apk add php-sodium
# RUN sed -i s/;extension=tidy/extension=tidy/ -f /usr/local/etc/php/php.ini-development
# RUN sed -i s/;extension=tidy/extension=tidy/ -f /usr/local/etc/php/php.ini-production
COPY php.ini /usr/local/etc/php/php.ini-development
COPY php.ini /usr/local/etc/php/php.ini-production
COPY php.ini /usr/local/etc/php/php.ini
CMD php -S 0.0.0.0:8080
Output from docker shell
on running phpinfo()
Server API => Command Line Interface
Virtual Directory Support => disabled
Configuration File (php.ini) Path => /usr/local/etc/php
Loaded Configuration File => /usr/local/etc/php/php.ini
Scan this dir for additional .ini files => /usr/local/etc/php/conf.d
Additional .ini files parsed => /usr/local/etc/php/conf.d/docker-php-ext-sodium.ini
# vi /usr/local/etc/php/php.ini
extension=tidy
[Tidy]
; The path to a default tidy configuration file to use when using tidy
; http://php.net/tidy.default-config
;tidy.default_config = /usr/local/lib/php/default.tcfg
; Should tidy clean and repair output automatically?
; WARNING: Do not use this option if you are generating non-html content
; such as dynamic images
; http://php.net/tidy.clean-output
tidy.clean_output = Off
; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
extension_dir = "/usr/lib/php7/modules/"
; On windows:
;extension_dir = "ext"
#ls /usr/lib/php7/modules/
curl.so sodium.so tidy.so zip.so
解决方案
有安装 php 库的 docker 命令。因此,不要使用 linux 命令,例如:apk add php-tidy
usingdocker-php-ext-install tidy
解决了我的问题。下面是有效的 docker 文件。
FROM php:7
ENV DEBIAN_FRONTEND noninteractive
USER root
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y apt-utils
RUN apt-get install -y libzip-dev
RUN apt-get install -y libtidy-dev
RUN apt-get install -y curl
RUN apt-get install -y libcurl3
RUN apt-get install -y libcurl3-dev
RUN docker-php-ext-install zip
RUN docker-php-ext-install curl
RUN docker-php-ext-install tidy
RUN docker-php-ext-enable zip
RUN docker-php-ext-enable curl
RUN docker-php-ext-enable tidy
COPY . code
WORKDIR code
EXPOSE 8080
CMD php -S 0.0.0.0:8080
推荐阅读
- amazon-web-services - 下载以纪元时间为文件名的 S3 文件
- javascript - MongoError:集合名称必须是字符串 - 即使我已经指定了字符串
- c - 如何处理以下错误代码:
- jquery - 如果这是空的(jQuery),则在 prev() 上设置类
- string - 有没有办法优化 KMP 算法以涉及我们正在比较的字符?
- swift - 全局变量/常量如何在 swift 中变得懒惰
- mongodb - CentOS for MongoDB 进程上的 bindIP 退出并显示错误代码
- java - 在 Spring Boot 中将文本值传递给 thymeleaf 视图
- c# - 单击该行时,DATAGRIDVIEW(允许用户添加行)被设置为空白
- javascript - 为什么将对象设置为不可扩展使其 [[prototype]] 不可变?