drra6593 2019-02-22 09:26
浏览 106

Php找不到整洁

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
  • 写回答

1条回答 默认 最新

  • doujia5863 2019-02-25 17:37
    关注

    There are docker commands to install php libraries. So instead of using linux command eg: apk add php-tidy using docker-php-ext-install tidy solved my problem. Below is the docker file that works.

    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

    </div>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘