ubuntu 中利用 docker 搭建 php + oracle 开发环境


利用 docker 部署 oracle 11g

安装 docker




Connect database with following setting:

hostname: localhost
port: 1521
sid: xe
username: system
password: oracle
Password for SYS & SYSTEM:

Connect to Oracle Application Express web management console with following settings:

workspace: INTERNAL
user: ADMIN
password: oracle

镜像详情:https://hub.docker.com/r/sath89/oracle-xe-11g/,利用 daocloud.io 可加速拉取镜像。

安装 Oracle Instant Client

Install RPMs

  1. Download the Oracle Instantclient RPM files from http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html. Everyone needs either “Basic” or “Basic lite”, and most users will want “SQL*Plus” and the “SDK”.

  2. Convert these .rpm files into .deb packages and install using “alien” (“sudo apt-get install alien” if you don’t have it).

  3. For example, for version for Linux x86_64 (64-bit):

  1. Test your Instantclient install by using “sqlplus” or “sqlplus64” to connect to your database:

If you execute sqlplus and get “sqlplus: command not found”, see the section below about adding the ORACLE_HOME variable.

If sqlplus complains of a missing libsqlplus.so file, follow the steps in the section “Integrate Oracle Libraries” below.

If sqlplus complains of a missing libaio.so.1 file, run

or, if you’re installing the 32 bit instant client on 64 bit,

Integrate Oracle Libraries

If oracle applications, such as sqlplus, are complaining about missing libraries, you can add the Oracle libraries to the LD_LIBRARY_PATH each time it is used:

For example, 12.1 version for Linux x86_64:

or to add it to the system library list create a new file as follows:

and add the oracle library path as the first line. For example,


Then run ldconfig:


Many Oracle database applications look for Oracle software in the location specified in the environment variable ‘ORACLE_HOME’.

Typical workstations will only have one Oracle install, and will want to define this variable in a system-wide location.

Add the following:

For example

Alternatively, each user can define this in their ~/.bash_profile

Note: From Ubuntu 11.04 (confirmed in 11.04 and 14.04) sqlplus was not recognized as a command unless the following line was also included in the oracle.sh file:


安装 php 扩展

1、下载并解压 oci8.so
2、复制到 /usr/lib/php/20151012/oci8.so
3、sudo vi /etc/php/7.0/mods-available/oci8.ini,将以下代码写入该文件:

注意文件权限应为 644
4、sudo phpenmod oci8
5、sudo service apache2 restart


电子邮件地址不会被公开。 必填项已用*标注