Hello!
After making several attempts to enable PDO_OCI support with a new image in Docker, I was notified that a source file is missing.
What I did, after reaching the “config.m4” files of the OCI and PDO_OCI extensions of the PHP source code in version 7.4.9:
-
1 - I downloaded the individual Oracle Instant Client Linux x64 packages (basic, sdk, tools, jdbc, odbc and sqlplus) from version 12.1.0.2.0;
-
2 - I organized a new ZIP package, containing the following structure (which was necessary to proceed in the stage of compiling the module)
- instantclient_12_1 /
| - lib /
| - sdk /
- instantclient_12_1 /
Being that:
a) “lib” contains all the aggregated content of the packages, with the exception of “sdk”;
b) in the root folder “instantclient_12_1” the files in the folder “lib” were replicated
*** Once again:** I reiterate that I did these steps to satisfy the build stage, since the module configuration files look for content within this model.
-
3 - I created the symbolic links to the files “libclntsh.so”, “libocci.so”, and “libclntshcore.so”
-
4 - I ran “ldconfig” and set the environment variables “LD_LIBRARY_PATH” and “ORACLE_HOME” pointing to the base location of the Oracle Instant Client.
This done and adjusted, after the progress of the image assembly, the console points out the following error:
*"In file include from /usr/src/php/ext/pdo_oci/pdo_oci.c:29:*
*/usr/src/php/ext/pdo_oci/php_pdo_oci_int.h:19:10 fatal error: oci.h: No such file or directory*
*#include <oci.h>*
*compilation terminated*
*make: *** [Makefile: 194: pdo_oci.io] Error 1 "*
Next, the DockerFile that I am using to create the image.
I’m using Docker Desktop 2.3.0.4 on Windows 10 Pro x64 operating system.
FROM php:7.4.9-apache
RUN apt-get update && apt-get install -y \
apt-utils \
unzip \
libaio-dev \
git \
locales \
build-essential \
libxml2 \
libxml2-dev \
apt-utils \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
libpq-dev \
libonig-dev \
libzip-dev \
zip \
&& apt-get clean -y
RUN echo "pt_BR ISO-8859-1" >> /etc/locale.gen
RUN locale-gen
# Oracle Instant Client stuff
ADD oci8/instantclient_12_1.zip /tmp/
RUN unzip /tmp/instantclient_12_1.zip -d /usr/local
RUN curl -O http://pear.php.net/go-pear.phar \
; /usr/local/bin/php -d detect_unicode=0 go-pear.phar
RUN ln -s /usr/local/instantclient_12_1/libclntsh.so.12.1 /usr/local/instantclient_12_1/libclntsh.so \
&& ln -s /usr/local/instantclient_12_1/libocci.so.12.1 /usr/local/instantclient_12_1/libocci.so \
&& ln -s /usr/local/instantclient_12_1/libclntshcore.so.12.1 /usr/local/instantclient_12_1/libclntshcore.so \
&& ln -s /usr/local/instantclient_12_1/sqlplus /usr/bin/sqlplus \
&& echo 'instantclient,/usr/local/instantclient_12_1' | pecl install oci8 \
&& ldconfig
ENV LANG pt_BR
ENV LD_LIBRARY_PATH /usr/local/instantclient_12_1
ENV ORACLE_HOME /usr/local/instantclient_12_1
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# PHP core extensions config and install
RUN docker-php-ext-configure pdo_mysql --with-pdo-mysql=mysqlnd \
&& docker-php-ext-configure mysqli --with-mysqli=mysqlnd \
&& docker-php-ext-configure bcmath \
&& docker-php-ext-configure intl \
&& docker-php-ext-configure pgsql --with-pgsql=/usr/local/pgsql \
&& docker-php-ext-configure pdo_oci --with-pdo-oci=instantclient,$ORACLE_HOME,12.1 \
&& docker-php-ext-install bcmath \
&& docker-php-ext-install gd \
&& docker-php-ext-install intl \
&& docker-php-ext-install mbstring \
&& docker-php-ext-install pgsql \
&& docker-php-ext-install pdo_pgsql \
&& docker-php-ext-install pdo_mysql \
&& docker-php-ext-install pdo_oci \
&& docker-php-ext-install xmlrpc \
&& docker-php-ext-install zip
# PHP PECL extensions add
RUN pecl install xdebug \
&& docker-php-ext-enable xdebug
RUN pecl install timezonedb \
&& docker-php-ext-enable timezonedb
# Use the custom php.ini file
ADD php/php.ini /usr/local/etc/php/php.ini
RUN a2enmod ssl
# Apache stuff
# Enable mod_rewrite
RUN ln -s /etc/apache2/mods-avaliable/rewrite.load /etc/apache2/mods-enabled/rewrite.load
# Add self signed certificate pair
ADD apache2/ssl.crt /etc/apache2/ssl/ssl.crt
ADD apache2/ssl.key /etc/apache2/ssl/ssl.key
# Override default website config
ADD apache2/000-default.conf /etc/apache2/conf-enabled/000-default.conf
# Container ports exposition
EXPOSE 9000 80 25 443