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
Recently I've decided to check out the Symfony Panther HTTP Client. I thought it would be nice to integrate that for testing and things.
I did follow the documentation very carefully. I have registered its extension for PHP unit. I can create a Panther client after extending the Panther Test Case - no problem there.
Problem shows when I try to make an actual call. Let's say:
$client = static::createPantherClient([ "--no-sandbox", "--headless", "window-size=1024,768"]);
$client->request('GET', '/mypage');
These options in the array - I was just trying things out, I thought it might help. The error I am getting is as follows:
1) App\Tests\Integration\Container\Controllers\ContainerControllerTest::test_read_container_by_slug
Facebook\WebDriver\Exception\UnknownErrorException: unknown error: Chrome failed to start: exited abnormally.
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/lib/chromium/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
I did look at the docs and SO for a solution but I can't really find anything that would help me.
Does anyone know why this is happening?
This is my Dockerfile for PHP
FROM php:7.4.3-fpm-alpine
WORKDIR /srv/app/
RUN apk update
RUN echo "extension=pdo_mysql" >> /usr/local/etc/php/php.ini-development
RUN docker-php-ext-install -j$(nproc) pdo_mysql
# php-redis
ENV PHPREDIS_VERSION 5.0.2
RUN docker-php-source extract \
&& curl -L -o /tmp/redis.tar.gz https://github.com/phpredis/phpredis/archive/$PHPREDIS_VERSION.tar.gz \
&& tar xfz /tmp/redis.tar.gz \
&& rm -r /tmp/redis.tar.gz \
&& mv phpredis-$PHPREDIS_VERSION /usr/src/php/ext/redis \
&& docker-php-ext-install redis \
&& docker-php-source delete
RUN apk add --no-cache \
unzip \
chromium \
chromium-chromedriver
ENV PANTHER_CHROME_DRIVER_BINARY /usr/lib/chromium/chromedriver
RUN docker-php-ext-install opcache
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
COPY conf/opcache.ini /usr/local/etc/php/conf.d/opcache.ini
Is there a way to assign a specific PHP version to a drupal Docker container?
I have a docker-compose file to link Drupal with MariaDB.
Everything works so far, but I want to assign a specific PHP version for migration purposes.
Since you are using the official image, they only come with specific php versions. Consider the below docker file of the official image
https://github.com/docker-library/drupal/blob/a8e09f524b89b61534f376e45b885d433d867c88/7/apache/Dockerfile
# from https://www.drupal.org/requirements/php#drupalversions
FROM php:7.0-apache
RUN a2enmod rewrite
# install the PHP extensions we need
RUN set -ex \
&& buildDeps=' \
libjpeg62-turbo-dev \
libpng12-dev \
libpq-dev \
' \
&& apt-get update && apt-get install -y --no-install-recommends $buildDeps && rm -rf /var/lib/apt/lists/* \
&& docker-php-ext-configure gd \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
&& docker-php-ext-install -j "$(nproc)" gd mbstring pdo pdo_mysql pdo_pgsql zip \
# PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20151012/gd.so' - libjpeg.so.62: cannot open shared object file: No such file or directory in Unknown on line 0
# PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20151012/pdo_pgsql.so' - libpq.so.5: cannot open shared object file: No such file or directory in Unknown on line 0
&& apt-mark manual \
libjpeg62-turbo \
libpq5 \
&& apt-get purge -y --auto-remove $buildDeps
WORKDIR /var/www/html
# https://www.drupal.org/node/3060/release
ENV DRUPAL_VERSION 7.56
ENV DRUPAL_MD5 5d198f40f0f1cbf9cdf1bf3de842e534
RUN curl -fSL "https://ftp.drupal.org/files/projects/drupal-${DRUPAL_VERSION}.tar.gz" -o drupal.tar.gz \
&& echo "${DRUPAL_MD5} *drupal.tar.gz" | md5sum -c - \
&& tar -xz --strip-components=1 -f drupal.tar.gz \
&& rm drupal.tar.gz \
&& chown -R www-data:www-data sites
Now create a copy of this. And change the top FROM php:7.0-apache to the the version you are interested in. You can see all the available versions below
https://hub.docker.com/r/library/php/tags/
And then rebuild the image to create your own drupal image with specific php version
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
I want to build my PHP-FPM image with php-redis extension based on the official PHP Docker image, for example, using this Dockerfile: php:5.6-fpm.
The docs say that I can install extensions this way, installing dependencies for extensions manually:
FROM php:5.6-fpm
# Install modules (iconv, mcrypt and gd extensions)
RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libpng12-dev \
&& docker-php-ext-install iconv mcrypt \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install gd
CMD ["php-fpm"]
Without Docker, I installed it with apt-get install php5-redis. But how can I install it using the approach above?
Redis is not an extension that is included in “php-src”, therefore you cannot use docker-php-ext-install. Use PECL:
RUN pecl install -o -f redis \
&& rm -rf /tmp/pear \
&& docker-php-ext-enable redis
On alpine php 7.3.5 we can use:
RUN apk add --no-cache pcre-dev $PHPIZE_DEPS \
&& pecl install redis \
&& docker-php-ext-enable redis.so
My opinion, the easiest way is:
RUN pecl install redis && docker-php-ext-enable redis
;)
Slightly revised version of starikovs and skyred answers for the current PHP 7 version of the docker image (tested on php:7.0.8-fpm-alpine and php:7.0.8-alpine).
Uses the newly released 3.0 version (June 2016) for PHP 7.
ENV PHPREDIS_VERSION 3.0.0
RUN mkdir -p /usr/src/php/ext/redis \
&& curl -L https://github.com/phpredis/phpredis/archive/$PHPREDIS_VERSION.tar.gz | tar xvz -C /usr/src/php/ext/redis --strip 1 \
&& echo 'redis' >> /usr/src/php-available-exts \
&& docker-php-ext-install redis
I've found two ways to install php-redis extension for official php-fpm Docker image. Here they are:
The first way is to compile redis from sources and install.
RUN curl -L -o /tmp/redis.tar.gz https://github.com/phpredis/phpredis/archive/2.2.7.tar.gz \
&& tar xfz /tmp/redis.tar.gz \
&& rm -r /tmp/redis.tar.gz \
&& mv phpredis-2.2.7 /usr/src/php/ext/redis \
&& docker-php-ext-install redis
docker-php-ext-install script is included in php-fpm image and can compile extensions and install them.
The second way you can do it is with PECL.
As TimWolla answered, you can do it with PECL, but in my case, PECL isn't installed by default.
RUN pecl install -o -f redis \
&& rm -rf /tmp/pear \
&& echo "extension=redis.so" > /usr/local/etc/php/conf.d/redis.ini
Based on #starikovs answer. I added a variable for docker style.
# install phpredis extension
ENV PHPREDIS_VERSION 2.2.7
RUN curl -L -o /tmp/redis.tar.gz https://github.com/phpredis/phpredis/archive/$PHPREDIS_VERSION.tar.gz \
&& tar xfz /tmp/redis.tar.gz \
&& rm -r /tmp/redis.tar.gz \
&& mv phpredis-$PHPREDIS_VERSION /usr/src/php/ext/redis \
&& docker-php-ext-install redis
If you want to use redis as session handler;
RUN { \
echo 'session.save_handler = redis'; \
echo 'session.save_path = tcp://redis:6379'; \
} >> /usr/local/etc/php/conf.d/docker-php-ext-redis.ini
If you want to use redis extension with PHP 7 in 2015 (borrowed from skyred's answer);
ENV PHPREDIS_VERSION php7
RUN curl -L -o /tmp/redis.tar.gz https://github.com/phpredis/phpredis/archive/$PHPREDIS_VERSION.tar.gz \
&& tar xfz /tmp/redis.tar.gz \
&& rm -r /tmp/redis.tar.gz \
&& mv phpredis-$PHPREDIS_VERSION /usr/src/php/ext/redis \
&& docker-php-ext-install redis
This works for alpine images:
RUN set -xe \
&& apk add --no-cache --update --virtual .phpize-deps $PHPIZE_DEPS \
&& pecl install -o -f redis \
&& echo "extension=redis.so" > /usr/local/etc/php/conf.d/redis.ini \
&& rm -rf /usr/share/php \
&& rm -rf /tmp/* \
&& apk del .phpize-deps
Edit: Added missing backslash
Tried few ways. On alpine php 7.3.5 we can use:
RUN apk add --no-cache pcre-dev $PHPIZE_DEPS \
&& pecl install redis \
&& docker-php-ext-enable redis.so
I'm using combination of PECL and PHP official docker extension script
RUN pecl bundle -d /usr/src/php/ext redis \
&& rm /usr/src/php/ext/redis-*.tgz \
&& docker-php-ext-install redis
For PHP7 you need to wait for official redis pecl release or use git:
RUN apt-get update \
&& apt-get install git -y -q \
&& git clone -b php7 https://github.com/phpredis/phpredis.git /usr/src/php/ext/redis \
&& docker-php-ext-install redis
Slightly revised version of starikovs and skyred answers for current version of the docker image.
Tested on php:5-fpm-alpine
# install phpredis extension
ENV PHPREDIS_VERSION 2.2.8
ADD https://github.com/phpredis/phpredis/archive/$PHPREDIS_VERSION.tar.gz /tmp/redis.tar.gz
RUN tar xzf /tmp/redis.tar.gz -C /tmp \
&& mkdir -p /usr/src/php/ext \
&& mv /tmp/phpredis-$PHPREDIS_VERSION /usr/src/php/ext/redis \
&& echo 'redis' >> /usr/src/php-available-exts \
&& docker-php-ext-install redis \
&& rm -rf /usr/src/php/ext/redis
In your Dockerfile you can clone the repo and install it with:
RUN git clone https://github.com/phpredis/phpredis.git /tmp/phpredis \
&& cd /tmp/phpredis \
&& git checkout -b 3.1.2 \ ## or the release you need #
&& phpize \
&& ./configure \
&& make \
&& make install
For image php:7.2-fpm-alpine.
RUN apk add autoconf gcc g++ make && pecl install redis && docker-php-ext-enable redis
You may need to update before
apk --update upgrade