PECL / PHP PDO_OCI extension obsolete. How to proceed?

2

I need to install the pdo_oci PHP extension to work with Oracle database via PDO. However, I noticed that the extension available via PECL is deprecated and will no longer be maintained.

As I understand this link (I do not know if I understood correctly), the latest versions of PHP already come with or PDO_OCI.

I would like to know how to proceed, as I have not found anything conclusive. I am using CentOS 6.6 with PHP 5.6.

NOTE: I have already installed the RPACs basic and devel of the ORACLE Instanclient

Thank you.

    
asked by anonymous 27.06.2015 / 19:37

2 answers

0

Thank you @ guilerme-birth. I was able to install as follows (remembering that I use CentOS 6.6):

Download PHP

  

$ wget link

Unzip and switch to the unzipped folder

  

$ tar -xzf php-5.6.10.tar.gz
  $ cd php-5.6.10

Run the configure command with the desired parameters (below my example)

  

./ configure
  --prefix = / usr
  --sysconfdir = / etc
  --localstatedir = / var
  --datadir = / usr / share / php
  --mandir = / usr / share / man
  --with-config-file-path = / etc
  --with-config-file-scan-dir = / etc / php.d
  --with-zlib
  --enable-bcmath
  --with-bz2
  --enable-calendar
  --with-gdbm
  --with-gmp
  --enable-ftp
  --with-gettext
  --enable-mbstring
  --with-readline
  --with-apxs2
  --with-pdo-oci = instantclient, / usr, 12.1
  --enable-dba = shared
  --with-pdo-mysql --with-mysql-sock = / var / mysql / mysql.sock
  --with-pdo-pgsql

OBS: Errors can occur during this step because of dependencies that need to be installed before, such as db4 and db4-devel. In my case, I ran the command, seeing which dependency was giving error. Once identified, I would install the dependency (always installing also the devel version of each package) and ran it again to see the next missing dependency. I did this until the command ran without errors.

Compiling and installing

  

$ make & make install

At this point, PHP is already installed. To make sure, run the following command:

  

$ php -v

But before we finish, we need to make some adjustments ...

Copy php.ini to the correct directory

  

If you are on a local server
  $ cp php.ini-development /etc/php.ini
If you are on a production server
  $ cp php.ini-production /etc/php.ini

Open apache configuration file for editing

  

$ vi /etc/httpd/conf/httpd.conf

Add the lines below for Apache to interpret PHP

  

AddType application / x-httpd-php .php
  AddType application / x-httpd-php-source .phps

Save and restart Apache

  

$ service httpd restart

Ready! It should all be working properly now!

The disadvantage of this method (at least as far as I've noticed) is that whenever you need a module such as PDO_MYSQL, PDO_PGSQL etc, you can not install via package as it will not work. To install some, it can be via PECL, except those that are outdated, such as PDO_MYSQL and PDO_OCI, where you must compile php again to install these.

    
28.06.2015 / 17:14
1

As the link what is obsolete is the PECL version, since PHP5.3 this extension is the default in PHP and therefore the PECL repository may have been deprecated.

If the extensions are not already on the server, I recommend installing using command:

yum install php-pdo

Installing OCI8 as a statically compiled extension

Configure PHP to include OCI8 using one of the following lines:

  • If you are using Oracle Instant Client do this:

    ./configure --with-oci8=instantclient,/path/to/instant/client/lib
    
  • If you are using Oracle database or full Oracle Client:

    ./configure --with-oci8=$ORACLE_HOME
    

After setup, follow the normal compilation steps, ex: make install

Installing OCI8 as a "Shared" extension

The shared configuration option builds OCI8 as a shared library that can be loaded dynamically into PHP. Building a shared extension allows OCI8 to be updated easily without affecting the rest of PHP.

  • If you are using the "free" Oracle Instant Client libraries:

    ./configure --with-oci8=shared,instantclient,/path/to/instant/client/lib
    

    If the Instant Client was installed through ZIP files, create the symbolic links first, for example: ln -s libclntsh.so.12.1 libclntsh.so

  • If you are using an Oracle Instant Client RPM-based installation:

    ./configure --with-oci8=shared,instantclient,/usr/lib/oracle/<version>/client/lib
    

    For example --with-oci8=shared,instantclient,/usr/lib/oracle/12.1/client/lib

    Note that initial support for the Oracle Instant Client appeared in PHP 4.3.11 and 5.0.4, originally used with --with-oci8-instant-client to configure PHP.

  • If you are using Oracle database or full Oracle Client installation:

    ./configure --with-oci8=shared,$ORACLE_HOME
    

    Verify that the web server user (nobody, www) has access to the libraries, initializing the files and tnsnames.ora (if using) under the $ORACLE_HOME directory. With Oracle 10gR2, you may need to run the $ORACLE_HOME/install/changePerm.sh utility to give access to the directory.

Enable php.ini

To enable "Oracle" in PHP you should open the php.ini file and uncomment the line (remove ; from start):

;extension=pdo.so
;extension=pdo_oci.so
;extension=pdo_oci8.so

Looking like this:

extension=pdo.so
extension=pdo_oci.so
extension=pdo_oci8.so

and restart the server.

If the OracleInstantClient is not "working", it may be the wrong version for PHP. Try downloading the correct version for your server from this link:

link

Note that the PDO extension for PHP is experimental :

  

This extension is EXPERIMENTAL. The behavior of this extension including the names of its functions and any other documentation surrounding this extension may change without notice in the future release of PHP. This extension should be used at your own risk.

Due to this fact, if you encounter any problems, try using the oci8.so functions, see: Connect PHP with Oracle

    
27.06.2015 / 19:59