How to add oracle extension to php in docker container under Alpine system

In this environment, PHP in the container is quickly installed through apk. Other extension modules can be installed through the apk add php7-redis command. The Oracle module needs to be compiled and installed.

Log in to the php container and execute the following command:

# docker exec -it php7 /bin/bash

# apk php-devel  php7-dev gcc musl-dev libnsl libaio g++  automake autoconf libtool make

# wget  https://raw.githubusercontent.com/bumpx/oracle-instantclient/master/instantclient-basic-linux.x64-11.2.0.4.0.zip

# wget https://raw.githubusercontent.com/bumpx/oracle-instantclient/master/instantclient-sdk-linux.x64-11.2.0.4.0.zip

# wget http://pecl.php.net/get/oci8-2.1.8.tgz

#Download the binary package of the corresponding version

# wget https://www.php.net/distributions/php-7.1.33.tar.bz2 

#unzip package

#  unzip instantclient-basic-linux.x64-11.2.0.4.0.zip

#  unzip instantclient-sdk-linux.x64-11.2.0.4.0.zip

#An instantclient_11_2 directory will be generated in the current directory.

# cd instantclient_11_2/

# ln -s libnnz11.so libnnz.so &&  ln -s libclntsh.so.11.1 libclntsh.so && ln -s libocci.so.11.1 libocci.so &&  cd .. &&  mv instantclient_11_2 /usr/local/lib/instantclient

# ln -s /usr/local/lib/instantclient/lib* /usr/lib && ln -s /usr/lib/libnsl.so.2.0.0 /usr/lib/libnsl.so.1

#Install oci8 module

# tar -xvf oci8-2.1.8.tgz

# cd oci8-2.1.8 

# phpize &&  ./configure --with-php-config=/usr//bin/php-config --with-oci8=shared,instantclient,/usr/local/lib/instantclient && make  && make install

# echo 'extension=oci8.so' >> /etc/php7/php.ini

# php -m|grep oci8

 father8

#Install pdo_oci module

# tar -xvf php-7.1.33.tar.bz2 && cd php-7.1.33

# phpize && ./configure --with-php-config=/usr/bin/php-config --with-pdo-oci=instantclient,/usr/local/lib/instantclient && make && make install

Since the pdo module configuration must be placed in front of pdo_oci, the pdo_oci module can be loaded normally, so delete the pdo module file and add it to the php.ini configuration file.

# mv /etc/php7/conf.d/00_pdo.ini /tmp

# echo 'extension=pdo.so' >> /etc/php7/php.ini

# echo 'extension=pdo_oci.so' >> /etc/php7/php.ini

# php -m|grep OCI

 PDO_OCI

So far the installation is successful

Guess you like

Origin blog.csdn.net/weixin_42272246/article/details/128223079