高山 linux 上的甲骨文 [英] Oracle on Alpine linux
问题描述
我正在尝试在我的 Alpine Linux Docker 环境中安装 OCI8 扩展.虽然有几个地方说它不起作用,但也有一些说它确实有效.我有一个 3.4
版本,出于公司原因,它现在保持这样.
I am trying to install OCI8 extension on my Alpine Linux Docker environment. Although there are several places saying it won't work, there are some which say it actually does. I have a 3.4
version and for corporate reasons it is staying like that for now.
我已经在我的 Docker conf 中做到了这一点:
I have done this within my Docker conf:
# Install Oracle Client and build OCI8 (Oracel Command Interface 8 - PHP extension)
USER root
ENV LD_LIBRARY_PATH=/usr/local/instantclient
ENV ORACLE_HOME=/usr/local/instantclient
RUN apk update && apk upgrade
RUN apk add musl-dev libaio autoconf && apk add --update make
## Unzip Instant Client v12
RUN pecl channel-update pecl.php.net
COPY instantclient_12_2.zip /var/www/html/instantclient_12_2.zip
RUN unzip -d /usr/local/ /var/www/html/instantclient_12_2.zip
RUN ln -s /usr/local/instantclient_12_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
RUN apk add gcc; exit 0 # This has a history of failing sometimes
RUN echo "instantclient,/usr/local/instantclient" | pecl install oci8 &&
echo 'extension=oci8.so' > /usr/local/etc/php/conf.d/30-oci8.ini &&
rm -rf /tmp/*.zip /var/cache/apk/* /tmp/pear/
现在构建通过了,看起来还可以,但是当我执行 php -v
时,我得到以下信息:
Now the build passes, and it looks okay, however when I do a php -v
I am getting the following:
PHP 警告:PHP 启动:无法加载动态库'/usr/local/lib/php/extensions/no-debug-non-zts-20160303/oci8.so' -加载共享库 libnsl.so.1 时出错:没有这样的文件或目录(/usr/local/instantclient/libclntsh.so.12.1 需要)在 Unknown on第 0 行
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20160303/oci8.so' - Error loading shared library libnsl.so.1: No such file or directory (needed by /usr/local/instantclient/libclntsh.so.12.1) in Unknown on line 0
PHP 版本为 7.1.12
.
我尝试过的是 apk add libnsl
但这会返回这个错误:
What I've tried is doing apk add libnsl
but this returns me this error:
错误:不可满足的约束:so:libtirpc.so.3(缺失):
ERROR: unsatisfiable constraints: so:libtirpc.so.3 (missing):
所以我还尝试添加 apk add libtirpc-dev
(普通"libtirpc
不适用于我的版本或其他版本),但这没有任何改变.
So I tried also adding apk add libtirpc-dev
(the 'plain' libtirpc
isn't available for my version or something), but that changed nothing.
有什么线索吗?
推荐答案
我分享了我的 docker 版本,该版本用于与最新版本的 alpine 和 Instantclient basiclite 配合使用.docker 镜像的大小为 124 mb.
I share my version of docker that I made to work with the latest version of alpine and instantclient basiclite. The size of the docker image is 124 mb.
我分享了我的github,你可以在那里下载
I share my github where you can download it
Docker + alpine + Instantclient Basiclite
或者你可以在下面看到dockerfile的内容
Or you can see below the content of the dockerfile
FROM alpine:latest
# Install Instantclient Basic Light Oracle and Dependencies
RUN apk --no-cache add libaio libnsl libc6-compat curl &&
cd /tmp &&
curl -o instantclient-basiclite.zip https://download.oracle.com/otn_software/linux/instantclient/instantclient-basiclite-linuxx64.zip -SL &&
unzip instantclient-basiclite.zip &&
mv instantclient*/ /usr/lib/instantclient &&
rm instantclient-basiclite.zip &&
ln -s /usr/lib/instantclient/libclntsh.so.19.1 /usr/lib/libclntsh.so &&
ln -s /usr/lib/instantclient/libocci.so.19.1 /usr/lib/libocci.so &&
ln -s /usr/lib/instantclient/libociicus.so /usr/lib/libociicus.so &&
ln -s /usr/lib/instantclient/libnnz19.so /usr/lib/libnnz19.so &&
ln -s /usr/lib/libnsl.so.2 /usr/lib/libnsl.so.1 &&
ln -s /lib/libc.so.6 /usr/lib/libresolv.so.2 &&
ln -s /lib64/ld-linux-x86-64.so.2 /usr/lib/ld-linux-x86-64.so.2
ENV ORACLE_BASE /usr/lib/instantclient
ENV LD_LIBRARY_PATH /usr/lib/instantclient
ENV TNS_ADMIN /usr/lib/instantclient
ENV ORACLE_HOME /usr/lib/instantclient
这篇关于高山 linux 上的甲骨文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!