本文介绍了如何通过docker-php-ext安装来安装PHP的扩展?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了,我现在正在尝试通过



安装mysql pdo pre> docker-php-ext-install

如。



但是我的通话失败了:

 已安装库:
/ usr / src / php / ext / mysqli / modules

如果您碰巧要链接到在给定目录LIBDIR中安装的库
,您必须使用libtool,
指定库的完整路径名,或者在链接过程中使用`-LLIBDIR'
标志,至少做以下之一:
- 在执行期间将LIBDIR添加到LD_LIBRARY_PATH环境变量

- 将LIBDIR添加到LD_RUN_PATH环境变量
d链接
- 使用`-Wl, - rpath -Wl,LIBDIR'链接器标记
- 让您的系统管理员将LIBDIR添加到/etc/ld.so.conf'

有关
更多信息的共享库的操作系统文档,例如ld(1)和ld.so(8)手册页。
---------------------------------------------- ------------------------

构建完成。
不要忘记运行'make test'。

安装共享扩展名:/ usr / local / lib / php / extensions / no-debug-non-zts-20131226 /
安装头文件:/ usr / local / include / php /
查找。 -name \ * .gcno -o -name \ * .gcda | xargs rm -f
find。 -name \ * .lo -o -name \ * .o | xargs rm -f
find。 -name \ * .la -o -name \ * .a | xargs rm -f
find。 -name \ * .so | xargs rm -f
find。 -name .libs -a -type d | xargs rm -rf
rm -f libphp.la modules / * libs / *
+ cd / usr / src / php / ext / mysqlnd
+ phpize
找不到config.m4。
确保在模块的顶级源目录中运行'/ usr / local / bin / phpize'

错误:服务'phlaconapp'无法构建:命令'/ bin / sh -c docker-php-ext-install mysqli mysqlnd pdo pdo_mysql zip'返回一个非零代码:1

这是我的 docker-compose.yml

  phlaconapp:
hostname:phaclonapp
dockerfile:Dockerfile
build:./
ports:
- 1080:80
- 1043:433
环境:
TERM:xterm-color
ENVIRONMENT:dev
卷:
- ./:/var/www/html/
链接:
- mysql
mysql:
image:mysql:5.6
卷:
- ./docker/mysql.d:/etc/mysql/conf.d
ports:[3306:3306]
环境:
MYSQL_ROOT_PASSWORD:'root'

这是我的 Dockerfile

  FROM php:5.6-apache 

运行php -rcopy('https://getcomposer.org/installer','composer-setup。 PHP'); &安培;&安培; \\'
php -rif(hash_file('SHA384','composer-setup.php')==='070854512ef404f16bac87071a6db9fd9721da1684cd4589b1196c3faf71b9a2682e2311b36a5079825e155ac7ce150d'){echo'Installer verified';} else {echo'Installer corrupt'; unlink ('composer-setup.php');} echo PHP_EOL; &安培;&安培; \
php composer-setup.php&& \
php -runlink('composer-setup.php');


运行apt-get update&& \
apt-get install vim git -y
RUN docker-php-ext-install mysqli mysqlnd pdo pdo_mysql zip

RUN cd /&& \
git clone --depth = 1 git://github.com/phalcon/cphalcon.git&&& \
cd cphalcon / build&& \
./install

RUN echoextension = phalcon.so> /usr/local/etc/php/conf.d/phalcon.ini
运行a2enmod重写

并运行 docker-compose build 将不会完成。

解决方案

我以前有同样的问题。我启动了一个容器,并将ext-install命令输入到这个容器中。一旦我找到所有的依赖项,我将它们写入docker文件。



Exmample:

 运行apt-get update&& apt-get install -y \ 
libmcrypt-dev \
&&& docker-php-ext-install -j $(nproc)mcrypt

有一个依赖的libmcrypt-我需要开发人员,然后才能使用docker-php-ext-install mcrypt



我检查了我的旧Dockerfiles,并找到可能会帮助您的一些东西$ /
$ b

  FROM php:5.6-apache 

RUN apt-get update&& apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libpng12-dev \
libicu-dev \
libxml2-dev \
vim \
wget \
解压缩\
git \
&& docker-php-ext-install -j $(nproc)iconv intl xml soap mcrypt opcache pdo pdo_mysql mysqli mbstring \
&& docker-php-ext-configuration gd --with-freetype-dir = / usr / include / --with-jpeg-dir = / usr / include / \
&& docker-php-ext-install -j $(nproc)gd

RUN a2enmod rewrite&& mkdir / composer-setup&& wget https://getcomposer.org/installer -P / composer-setup& amp;& php / composer-setup / installer --install-dir = / usr / bin& amp;& rm -Rf / composer-setup&&卷曲-LsS https://symfony.com/installer -o / usr / local / bin / symfony& amp;& chmod a + x / usr / local / bin / symfony
#为默认conf创建符号链接
RUN ln -s /etc/apache2/sites-available/000-default.conf / etc / apache2 / sites -enabled / 000-default.conf&&& mkdir / composer-setup&& wget https://getcomposer.org/installer -P / composer-setup& amp;& php / composer-setup / installer --install-dir = / usr / bin& amp;& rm -Rf / composer-setup&&卷曲-LsS https://symfony.com/installer -o / usr / local / bin / symfony& amp;& chmod a + x / usr / local / bin / symfony


In order to resolve an issue, I am now trying install the mysql pdo via

docker-php-ext-install

as pointed out in the README of the php image.

Yet my call fails stating:

Libraries have been installed in:
   /usr/src/php/ext/mysqli/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

Build complete.
Don't forget to run 'make test'.

Installing shared extensions:     /usr/local/lib/php/extensions/no-debug-non-zts-20131226/
Installing header files:           /usr/local/include/php/
find . -name \*.gcno -o -name \*.gcda | xargs rm -f
find . -name \*.lo -o -name \*.o | xargs rm -f
find . -name \*.la -o -name \*.a | xargs rm -f
find . -name \*.so | xargs rm -f
find . -name .libs -a -type d|xargs rm -rf
rm -f libphp.la       modules/* libs/*
+ cd /usr/src/php/ext/mysqlnd
+ phpize
Cannot find config.m4.
Make sure that you run '/usr/local/bin/phpize' in the top level source directory of the module

ERROR: Service 'phlaconapp' failed to build: The command '/bin/sh -c docker-php-ext-install mysqli mysqlnd pdo pdo_mysql zip' returned a non-zero code: 1

This is my docker-compose.yml:

phlaconapp:
    hostname: phaclonapp
    dockerfile: Dockerfile
    build: ./
    ports:
        - "1080:80"
        - "1043:433"
    environment:
        TERM: xterm-color
        ENVIRONMENT: dev
    volumes:
        - ./:/var/www/html/
    links:
        - mysql
mysql:
    image: mysql:5.6
    volumes:
        - ./docker/mysql.d:/etc/mysql/conf.d
    ports: ["3306:3306"]
    environment:
        MYSQL_ROOT_PASSWORD: 'root'

This is my Dockerfile:

FROM php:5.6-apache

RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \
    php -r "if (hash_file('SHA384', 'composer-setup.php') === '070854512ef404f16bac87071a6db9fd9721da1684cd4589b1196c3faf71b9a2682e2311b36a5079825e155ac7ce150d') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" && \
    php composer-setup.php && \
    php -r "unlink('composer-setup.php');"


RUN apt-get update && \
    apt-get install vim git -y
RUN docker-php-ext-install mysqli mysqlnd pdo pdo_mysql zip

RUN  cd /  && \
    git clone --depth=1 git://github.com/phalcon/cphalcon.git && \
    cd cphalcon/build && \
    ./install

RUN echo "extension=phalcon.so" > /usr/local/etc/php/conf.d/phalcon.ini
RUN a2enmod rewrite

and running docker-compose build won't finish.

解决方案

I had the same problem a whil ago. I started a container and typed the ext-install commands into this container. Once I found all the dependencies I wrote them into the dockerfile.

Exmample:

RUN apt-get update && apt-get install -y \
libmcrypt-dev \
&& docker-php-ext-install -j$(nproc) mcrypt

There is an dependencie that libmcrypt-dev is needed before you can docker-php-ext-install mcrypt

I've checked my older Dockerfiles and found something which might help you

FROM php:5.6-apache

RUN apt-get update && apt-get install -y \
        libfreetype6-dev \
        libjpeg62-turbo-dev \
        libmcrypt-dev \
        libpng12-dev \
    libicu-dev \
     libxml2-dev \
    vim \
        wget \
        unzip \
        git \
    && docker-php-ext-install -j$(nproc) iconv intl xml soap mcrypt opcache pdo pdo_mysql mysqli mbstring \
    && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
    && docker-php-ext-install -j$(nproc) gd

RUN a2enmod rewrite && mkdir /composer-setup && wget https://getcomposer.org/installer -P /composer-setup && php /composer-setup/installer --install-dir=/usr/bin && rm -Rf /composer-setup && curl -LsS https://symfony.com/installer -o /usr/local/bin/symfony && chmod a+x /usr/local/bin/symfony
# Create symlink for default conf
RUN ln -s /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-enabled/000-default.conf && mkdir /composer-setup && wget https://getcomposer.org/installer -P /composer-setup && php /composer-setup/installer --install-dir=/usr/bin && rm -Rf /composer-setup && curl -LsS https://symfony.com/installer -o /usr/local/bin/symfony && chmod a+x /usr/local/bin/symfony

这篇关于如何通过docker-php-ext安装来安装PHP的扩展?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 04:14