I am migrating an extremely old and legacy system written in PHP. Currently I have made good progress, however, the code makes use of a library called PHPLot where it is dependent on php-gd.
I've done everything ... I've been trying to install this dependence for 3 days. Can you help me?
Here's my 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/
UPDATE:
I was able to solve the problem. Here's my code with the solution:
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/
On your ./configure line:
To enable GD-support configure PHP --with-gd[=DIR] , where DIR is the GD base install directory. To use the recommended bundled version of the GD library, use the configure option --with-gd . GD library requires libpng and libjpeg to compile.
http://php.net/manual/en/image.installation.php
Related
I'm trying to install oci8-2.2.0 on an ubuntu 18 docker with php 7.2
I'm using the following commands (php-pear and libc6 installed before those):
RUN apt-get update && \
apt-get install -y unzip libaio1 libsnl-dev && \
cd /tmp && \
wget https://download.oracle.com/otn_software/linux/instantclient/214000/instantclient-sdk-linux.x64-21.4.0.0.0dbru.zip && \
wget https://download.oracle.com/otn_software/linux/instantclient/214000/instantclient-sqlplus-linux.x64-21.4.0.0.0dbru.zip && \
wget https://download.oracle.com/otn_software/linux/instantclient/214000/instantclient-basic-linux.x64-21.4.0.0.0dbru.zip && \
mkdir -p /opt/oracle && \
cp instantclient-* /opt/oracle/ && \
cd /opt/oracle/ && \
unzip instantclient-basic-linux.x64-21.4.0.0.0dbru.zip && \
unzip instantclient-sdk-linux.x64-21.4.0.0.0dbru.zip && \
unzip instantclient-sqlplus-linux.x64-21.4.0.0.0dbru.zip && \
rm -rf /var/lib/apt/lists/* instantclient-basic-linux.x64-21.4.0.0.0dbru.zip instantclient-sdk-linux.x64-21.4.0.0.0dbru.zip instantclient-sqlplus-linux.x64-21.4.0.0.0dbru.zip && \
ln -s /opt/oracle/instantclient_21_4/libclntsh.so.21.1 /usr/lib/libclntsh.so && \
ln -s /lib64/ld-linux-x86-64.so.2 /usr/lib/ld-linux-x86-64.so.2 && \
ln -s /opt/oracle/instantclient_21_4/libnnz21.so /usr/lib/libnnz21.so && \
ln -s /opt/oracle/instantclient_21_4/libclntshcore.so /usr/lib/libclntshcore.so.21.1 && \
echo /opt/oracle/instantclient_21_4 > /etc/ld.so.conf.d/oracle-instantclient.conf
RUN echo "instantclient,/opt/oracle/instantclient_21_4" | pecl install oci8-2.2.0 && \
echo "extension=oci8.so" >> /etc/php/7.2/cli/php.ini && \
echo "extension=oci8.so" >> /etc/php/7.2/apache2/php.ini
PHP Seems to recognize the module and load it, but when I call #oci_new_connect I don't get a connection, but I don't get an error either.
Using sqlplus from the same server connects just fine, so its not that. Another installation with the adminer 4.8.1 docker (alpine & php 7.4) works fine.
I'm completely stumped. Does anyone have an idea where to look next?
Found the issue, needed to add
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/oracle/instantclient_21_4
I'm just working on a laravel project which runs on docker using sail.For a feature i need to create functionality which can create thumbnails for pdf's.I figured out it is possible to done using php Imagick class/library.But unfortunately I'm struggling to install it on the project.Anyone knows how to install it using docker?Really appreciate.
This is the Dockerfile.
LABEL maintainer="Taylor Otwell"
ARG WWWGROUP
ARG NODE_VERSION=16
WORKDIR /var/www/html
ENV DEBIAN_FRONTEND noninteractive
ENV TZ=UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt-get update \
&& apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2 \
&& mkdir -p ~/.gnupg \
&& chmod 600 ~/.gnupg \
&& echo "disable-ipv6" >> ~/.gnupg/dirmngr.conf \
&& apt-key adv --homedir ~/.gnupg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys E5267A6C \
&& apt-key adv --homedir ~/.gnupg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C300EE8C \
&& echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu hirsute main" > /etc/apt/sources.list.d/ppa_ondrej_php.list \
&& apt-get update \
&& apt-get install -y php8.0-cli php8.0-dev \
php8.0-pgsql php8.0-sqlite3 php8.0-gd \
php8.0-curl php8.0-memcached \
php8.0-imap php8.0-mysql php8.0-mbstring \
php8.0-xml php8.0-zip php8.0-bcmath php8.0-soap \
php8.0-intl php8.0-readline php8.0-pcov \
php8.0-msgpack php8.0-igbinary php8.0-ldap \
php8.0-redis php8.0-swoole php8.0-xdebug \
&& php -r "readfile('http://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer \
&& curl -sL https://deb.nodesource.com/setup_$NODE_VERSION.x | bash - \
&& apt-get install -y nodejs \
&& npm install -g npm \
&& curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list \
&& apt-get update \
&& apt-get install -y yarn \
&& apt-get install -y mysql-client \
&& apt-get install -y postgresql-client \
&& apt-get -y autoremove \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN update-alternatives --set php /usr/bin/php8.0
RUN setcap "cap_net_bind_service=+ep" /usr/bin/php8.0
RUN groupadd --force -g $WWWGROUP sail
RUN useradd -ms /bin/bash --no-user-group -g $WWWGROUP -u 1337 sail
COPY start-container /usr/local/bin/start-container
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY php.ini /etc/php/8.0/cli/conf.d/99-sail.ini
RUN chmod +x /usr/local/bin/start-container
EXPOSE 8000
ENTRYPOINT ["start-container"]
The easiest way is to use mlocati/docker-php-extension-installer like this:
FROM php:8.0
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN chmod +x /usr/local/bin/install-php-extensions && \
install-php-extensions imagick
When running docker-compose up I am getting the following error:
Service 'web-app' failed to build: The command '/bin/sh -c set -xe && buildDeps=" $PHP_EXTRA_BUILD_DEPS libcurl4-openssl-dev libedit-dev libsqlite3-dev libssl-dev libxml2-dev xz-utils " && apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* && curl -fSL "http://php.net/get/$PHP_FILENAME/from/this/mirror" -o "$PHP_FILENAME" && echo "$PHP_SHA256 *$PHP_FILENAME" | sha256sum -c - && curl -fSL "http://php.net/get/$PHP_FILENAME.asc/from/this/mirror" -o "$PHP_FILENAME.asc" && export GNUPGHOME="$(mktemp -d)" && for key in $GPG_KEYS; do gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; done && gpg --batch --verify "$PHP_FILENAME.asc" "$PHP_FILENAME" && rm -r "$GNUPGHOME" "$PHP_FILENAME.asc" && mkdir -p /usr/src/php && tar -xf "$PHP_FILENAME" -C /usr/src/php --strip-components=1 && rm "$PHP_FILENAME" && cd /usr/src/php && ./configure --with-config-file-path="$PHP_INI_DIR" --with-config-file-scan-dir="$PHP_INI_DIR/conf.d" $PHP_EXTRA_CONFIGURE_ARGS --disable-cgi --enable-mysqlnd --enable-mbstring --with-curl --with-libedit --with-openssl --with-zlib && make -j"$(nproc)" && make install && { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } && make clean && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps' returned a non-zero code: 2
Any idea why and how to fix it please?
I am trying to use wkhtmltopdf in a container with Docker and Symfony.
The installation is done well, but the result is very different from the reality, so I think some libraries must be missing in the system, but I don't know which one.
I've been checking other questions here and in google, but they don't help.
FROM phpdockerio/php71-fpm:latest
# Fix debconf warnings upon build
ARG DEBIAN_FRONTEND=noninteractive
# Install selected extensions and other stuff
RUN apt-get update \
&& apt-get -y --no-install-recommends install cron \
php7.1-mysql \
php-redis \
php7.1-bcmath \
php7.1-gd \
php-imagick \
php7.1-intl \
cron \
python \
xz-utils \
libxrender1 \
libfontconfig1 \
zlib1g \
fontconfig \
libfreetype6 \
libx11-6 \
libxext6 \
wkhtmltopdf
RUN curl --insecure https://getcomposer.org/composer.phar -o /usr/bin/composer && chmod +x /usr/bin/composer
RUN cd /tmp \
&& curl "https://downloads.wkhtmltopdf.org/0.12/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz" -L -o "wkhtmltopdf.tar.xz" \
&& tar Jxvf wkhtmltopdf.tar.xz \
&& rm wkhtmltopdf.tar.xz \
&& mv wkhtmltox/include/* /usr/local/include/ \
&& mv wkhtmltox/lib/* /usr/local/lib/ \
&& mv wkhtmltox/bin/* /usr/local/bin/ \
&& mv wkhtmltox/share/* /usr/local/share/
RUN apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
CMD php-fpm -F
This is the result in the container(docker)
And this is the result on my machine (without docker), as it should be.
Any idea what might be happening?
I'm trying to compile PHP OCI8 extension and run it under Alpinelinux. But it seems extension has some dependencies on symbols defined in glibc but missing in musl libc.
Is there any existent compiled PHP OCI8 extension I can use? Or is there any workaround to make oci8 extension and oracle instant client work with alpinelinux.
Thanks in advance!
My solution for Alpine turned out to be simple: use Instant Client v11 (11.2.0.4) instead of v12 (12.2.0.1):
ENV LD_LIBRARY_PATH /usr/local/instantclient
ENV ORACLE_HOME /usr/local/instantclient
# Install Oracle Client and build OCI8 (Oracle Command Interface 8 - PHP extension)
RUN apk add php7-pear php7-dev gcc musl-dev libnsl libaio &&\
## Download and unarchive Instant Client v11
curl -o /tmp/basic.zip https://raw.githubusercontent.com/bumpx/oracle-instantclient/master/instantclient-basic-linux.x64-11.2.0.4.0.zip && \
curl -o /tmp/sdk.zip https://raw.githubusercontent.com/bumpx/oracle-instantclient/master/instantclient-sdk-linux.x64-11.2.0.4.0.zip && \
curl -o /tmp/sqlplus.zip https://raw.githubusercontent.com/bumpx/oracle-instantclient/master/instantclient-sqlplus-linux.x64-11.2.0.4.0.zip && \
unzip -d /usr/local/ /tmp/basic.zip && \
unzip -d /usr/local/ /tmp/sdk.zip && \
unzip -d /usr/local/ /tmp/sqlplus.zip && \
## Links are required for older SDKs
ln -s /usr/local/instantclient_11_2 ${ORACLE_HOME} && \
ln -s ${ORACLE_HOME}/libclntsh.so.* ${ORACLE_HOME}/libclntsh.so && \
ln -s ${ORACLE_HOME}/libocci.so.* ${ORACLE_HOME}/libocci.so && \
ln -s ${ORACLE_HOME}/lib* /usr/lib && \
ln -s ${ORACLE_HOME}/sqlplus /usr/bin/sqlplus &&\
ln -s /usr/lib/libnsl.so.2.0.0 /usr/lib/libnsl.so.1 &&\
## Build OCI8 with PECL
echo "instantclient,${ORACLE_HOME}" | pecl install oci8 &&\
echo 'extension=oci8.so' > /etc/php7/conf.d/30-oci8.ini &&\
# Clean up
apk del php7-pear php7-dev gcc musl-dev &&\
rm -rf /tmp/*.zip /var/cache/apk/* /tmp/pear/
Try these commands.
It works under Docker on Alpine.
But, you have to install the GLIB Alpine compatibility layer: https://github.com/sgerrand/alpine-pkg-glibc
# Install OCI8
COPY ./oracle-sdk /tmp/oracle-sdk
RUN apk add --no-cache libaio-dev && \
unzip /tmp/oracle-sdk/instantclient-basic-linux.x64-12.2.0.1.0.zip -d /usr/local/ && \
unzip /tmp/oracle-sdk/instantclient-sdk-linux.x64-12.2.0.1.0.zip -d /usr/local/ && \
unzip /tmp/oracle-sdk/instantclient-sqlplus-linux.x64-12.2.0.1.0.zip -d /usr/local/ && \
ln -s /usr/local/instantclient_12_2 /usr/local/instantclient && \
ln -s /usr/local/instantclient/libclntsh.so.* /usr/local/instantclient/libclntsh.so && \
ln -s /usr/local/libclntshcore.so.* /usr/local/instantclient/libclntshcore.so && \
ln -s /usr/local/instantclient/libocci.so.* /usr/local/instantclient/libocci.so && \
ln -s /usr/local/instantclient/sqlplus /usr/bin/sqlplus && \
docker-php-ext-configure oci8 --with-oci8=instantclient,/usr/local/instantclient && \
docker-php-ext-install oci8 && \
rm -rf /tmp/oracle-sdk
People who've tried Alpine haven't found a way. The problem is not specific to PHP, so check other languages that also use Oracle Instant Client and have tried Alpine. For example, see the Alpine issue https://github.com/sgerrand/alpine-pkg-glibc/issues/31
FROM php:alpine3.13
RUN apk add --no-cache composer libaio libc6-compat \
&& wget https://download.oracle.com/otn_software/linux/instantclient/211000/instantclient-basiclite-linux.x64-21.1.0.0.0.zip -O- | busybox unzip -q - \
&& wget https://download.oracle.com/otn_software/linux/instantclient/211000/instantclient-sdk-linux.x64-21.1.0.0.0.zip -O- | busybox unzip -q - \
&& cp /instantclient_21_1/libclntsh.so.21.1 /instantclient_21_1/libclntsh.so && cp /lib64/ld-linux-x86-64.so.2 /instantclient_21_1/ && cp /lib/libc.so.6 /usr/lib/libresolv.so.2 \
&& docker-php-ext-configure oci8 --with-oci8=instantclient,/instantclient_21_1 && docker-php-ext-install oci8