Docker - 安装PHP 5.2.17和php-gd

时间:2017-06-27 13:12:09

标签: php apache docker gd phplot

我正在迁移用PHP编写的极其古老而遗留的系统。目前我取得了很好的进展,但是,代码使用了一个名为PHPLot的库,它依赖于php-gd。

我已经完成了所有事情......我一直试图将这种依赖性安装3天。你能救我吗?

这是我的Dockerfile:

FROM httpd:2.2

MAINTAINER Marcus Campos <campos.v.marcus@gmail.com>

ENV HTTPD_CONF $HTTPD_PREFIX/conf/httpd.conf
ENV PHP_INI /usr/local/lib/php.ini
ENV HOME /root

RUN usermod -u 1000 www-data && groupmod -g 1000 www-data \
    && sed -i 's/User daemon/User www-data/' $HTTPD_CONF \
    && sed -i 's/Group daemon/Group www-data/' $HTTPD_CONF

WORKDIR $HOME

ADD http://www.geocities.jp/aoba_suzukaze/php-5.2.17.tar.bz2 .
ADD http://www.geocities.jp/aoba_suzukaze/libxml29_compat.patch .

RUN echo 'ServerName localhost:80' >> $HTTPD_CONF

RUN apt-get update && apt install -y --no-install-recommends bzip2 gcc     make libxml2-dev libmysqlclient-dev patch autoconf

RUN ln -sf /usr/lib/x86_64-linux-gnu/libmysqlclient.so /usr/lib/libmysqlclient.so \
    && ln -sf /usr/lib/x86_64-linux-gnu/libmysqlclient.a /usr/lib/libmysqlclient.a

RUN set -x \
    && tar -xf php-5.2.17.tar.bz2 \
    && cd php-5.2.17 \
    && patch -p0 < $HOME/libxml29_compat.patch \
    && ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --with-mysqli --with-pdo-mysql --enable-mbstring \
    && make -j"$(nproc)" \
    && make install \
    && cp php.ini-recommended $PHP_INI

RUN echo '<FilesMatch \.php$>' >> $HTTPD_CONF \
    && echo '    SetHandler application/x-httpd-php' >> $HTTPD_CONF \
    && echo '</FilesMatch>' >> $HTTPD_CONF

RUN sed -i 's/"GPCS"/"EGPCS"/' $PHP_INI

RUN pecl install xdebug-2.2.7 \
    && echo 'zend_extension="/usr/local/lib/php/extensions/no-debug-non-zts-20060613/xdebug.so"' >> $PHP_INI \
    && echo 'xdebug.remote_enable=On' >> $PHP_INI \
    && echo 'xdebug.remote_connect_back=On' >> $PHP_INI \
    && echo 'xdebug.remote_autostart=On' >> $PHP_INI \
    && echo 'xdebug.idekey="xdebug"' >> $PHP_INI

WORKDIR $HTTPD_PREFIX/htdocs/

更新:

我能够解决问题。这是解决方案的代码:

FROM httpd:2.2

MAINTAINER Marcus Campos <campos.v.marcus@gmail.com>

ENV HTTPD_CONF $HTTPD_PREFIX/conf/httpd.conf
ENV PHP_INI /usr/local/lib/php.ini
ENV HOME /root

RUN usermod -u 1000 www-data && groupmod -g 1000 www-data \
    && sed -i 's/User daemon/User www-data/' $HTTPD_CONF \
    && sed -i 's/Group daemon/Group www-data/' $HTTPD_CONF

WORKDIR $HOME

ADD http://www.geocities.jp/aoba_suzukaze/php-5.2.17.tar.bz2 .
ADD http://www.geocities.jp/aoba_suzukaze/libxml29_compat.patch .

RUN echo 'ServerName localhost:80' >> $HTTPD_CONF

RUN apt-get update && apt install -y --no-install-recommends bzip2 gcc make libxml2-dev libmysqlclient-dev patch autoconf libjpeg-dev libpng12-dev

RUN ln -sf /usr/lib/x86_64-linux-gnu/libmysqlclient.so /usr/lib/libmysqlclient.so \
    && ln -sf /usr/lib/x86_64-linux-gnu/libmysqlclient.a /usr/lib/libmysqlclient.a

RUN set -x \
    && ln -s /usr/lib/x86_64-linux-gnu/libjpeg.a /usr/lib/libjpeg.a \
    && ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib/libjpeg.so \
    && ln -s /usr/lib/x86_64-linux-gnu/libpng.a /usr/lib/libpng.a \
    && ln -s /usr/lib/x86_64-linux-gnu/libpng.so /usr/lib/libpng.so \
    && tar -xf php-5.2.17.tar.bz2 \
    && cd php-5.2.17 \
    && patch -p0 < $HOME/libxml29_compat.patch \
    && ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --with-mysqli --with-pdo-mysql --enable-mbstring \
    && make -j"$(nproc)" \
    && make install \
    && cp php.ini-recommended $PHP_INI

RUN echo '<FilesMatch \.php$>' >> $HTTPD_CONF \
    && echo '    SetHandler application/x-httpd-php' >> $HTTPD_CONF \
    && echo '</FilesMatch>' >> $HTTPD_CONF

RUN sed -i 's/"GPCS"/"EGPCS"/' $PHP_INI

RUN pecl install xdebug-2.2.7 \
    && echo 'zend_extension="/usr/local/lib/php/extensions/no-debug-non-zts-20060613/xdebug.so"' >> $PHP_INI \
    && echo 'xdebug.remote_enable=On' >> $PHP_INI \
    && echo 'xdebug.remote_connect_back=On' >> $PHP_INI \
    && echo 'xdebug.remote_autostart=On' >> $PHP_INI \
    && echo 'xdebug.idekey="xdebug"' >> $PHP_INI

WORKDIR $HTTPD_PREFIX/htdocs/

1 个答案:

答案 0 :(得分:0)

在你的./configure专栏:

要启用GD-support,请配置PHP --with-gd [= DIR],其中DIR是GD基本安装目录。要使用推荐的捆绑版GD库,请使用configure选项--with-gd。 GD库需要libpng和libjpeg才能编译。

http://php.net/manual/en/image.installation.php