4

我正在尝试编译PHP OCI8 扩展并在Alpinelinux下运行它。但似乎扩展对musl libcglibc中定义但缺少的符号有一些依赖性。

我可以使用任何现有的编译 PHP OCI8 扩展吗?或者是否有任何解决方法可以使 oci8 扩展和 oracle 即时客户端与 alpinelinux 一起使用。

提前致谢!

4

4 回答 4

5

我对 Alpine 的解决方案很简单:使用 Instant Client v11 (11.2.0.4) 而不是 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/
于 2018-08-10T15:39:25.737 回答
4

试试这些命令。

它在 Alpine 上的 Docker 下工作。

但是,您必须安装 GLIB Alpine 兼容层: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
于 2017-10-30T11:35:09.360 回答
1

尝试过 Alpine 的人还没有找到方法。该问题并非特定于 PHP,因此请检查也使用 Oracle Instant Client 并尝试过 Alpine 的其他语言。例如,查看 Alpine 问题https://github.com/sgerrand/alpine-pkg-glibc/issues/31

于 2016-07-22T02:07:49.403 回答
0
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
于 2021-06-23T18:08:00.273 回答