PHP and Oracle on Ubuntu Server|PHP e Oracle no Ubuntu Server

Here are a few steps to have your PHP with Oracle (OCI8) support. I assume you already have Apache and PHP running. I have tested this procedure with Ubuntu 8.04 (Hardy, LTS) Server Edition.
Segue alguns poucos passos para ter o PHP com suporte a Oracle (OCI8). Estou assumindo que Apache e PHP já estão instalados e executando. Testei estes procedimentos no Ubuntu 8.04 (Hardy, LTS) Server Edition.

Install some needed packages:
Instale alguns pacotes necessários:

sudo apt-get install php-pear php5-dev libaio1 build-essential

Baixe o Oracle Instant Client:
Download the Oracle Instant Client:

Você precisa dos pacotes:
You need the packages:

  • Basic client
  • SDK
  • SQL Plus (Optional)

Unzip all downloaded files in /opt/instantclient
Descompacte os arquivos baixados em /opt/instantclient

Execute os comandos abaixo:
Run the commands below:

cd /opt/instantclient
sudo ln -s
sudo ln -s
sudo sh -c ‘echo “/opt/instantclient” > /etc/’
sudo ldconfig

Vamos instalar o módulo OCI8:
Let’s install OCI8 module:

sudo pecl install oci8

Quando for perguntado o path (caminho) do Oracle, digite:
When asked for Oracle PATH, type:

all <ENTER>
instantclient,/opt/instantclient <ENTER>

Coloque a extensão recém criada nas configurações do PHP:
Put the newly created extension in PHP config:

sudo sh -c ‘echo “” > /etc/php5/conf.d/oracle.ini’

Reinicie o apache:
Restart your apache:

sudo /etc/init.d/apache2 restart

Verifique com phpinfo() se o módulo OCI8 foi carregado.
Check with phpinfo() if OCI8 module was loaded.

É isso!
That’s All!

5 thoughts on “PHP and Oracle on Ubuntu Server|PHP e Oracle no Ubuntu Server”

  1. Instead of the dirty ‘sudo sh -c ‘ you could also use ‘echo “text” | sudo tee /file’ and to append use tee -a. This also prevents another shell running as root, which is not what you need and a possible security risk.

  2. Bom dia Wendell, desculpa estar insistindo, mas continuo tendo problemas, ja tentei tudo mas nao consigo ter sucesso… segue abaixo o erro no meu sistema.

    /usr/bin/ld: skipping incompatible /opt/instantclient/ when searching for -lclntsh
    /usr/bin/ld: cannot find -lclntsh
    collect2: ld returned 1 exit status
    make: *** [] Error 1
    ERROR: `make’ failed

    PS.: meu Ubuntu é o 8.10 64bits

    Um abraço.

  3. you probably should try downloading the 64bit version of the instant client, i banged my head against the desk after finding out i spent 50 minutes stupidly due to this mistake.

Comments are closed.