Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Php PDO OCI Driver installation using pecl

I'm trying to install the PDO driver for OCI.

When searching Google for pdo_oci I find the following URL:

https://pecl.php.net/package/PDO_OCI

It displays this message at the top of the page:

This package is not maintained anymore and has been superseded. Package has moved to channel http://www.php.net/pdo_oci, package ext/pdo_oci.

What does this message mean, how do I add this channel using pecl?

I've attempted to add that channel using pear channel-discover php.net/pdo_oci, but it doesn't seem to work. I also can't find a channel.xml file for php.net/pdo_oci so I could try pear channel-add channel.xml.

like image 778
Zamicol Avatar asked Sep 20 '26 03:09

Zamicol


1 Answers

EDIT

If you already have php installed (from repository for example), you can compile only the PDO_OCI from PHP source (you need the instantclient installed)

  • Download the PHP source with same version that you have installed;
  • Unzip;
  • Change to directory php-YOUR-VERSION/ext/pdo_oci

Inside the pdo_oci folder, run these commands:

$ phpize  
$ ./configure --with-pdo-oci=instantclient,/usr,12.1  
$ make && make install  
$ echo "extension=pdo_oci.so" > /etc/php.d/pdo_oci.ini  
$ service httpd restart

This method will only create a pdo_oci.so in the PHP extensions folder, don't need to recompile entire PHP. You can do it with repositories versions of PHP, and can do it with any extension inside the ext folder in PHP source.


First, sorry for my bad english.

I had the same question, but I could already solve.

As the message says, this PECL extension is deprecated. You need to compile PHP from source with the PDO_OCI that is included in PHP Source.

I made this way in CentOS 6.6, with MySQL, Apache and InstantClient installed:

Install dependencies like

curl-devel
freetype-devel
libc-client
libc-client-devel
libjpeg-devel
libmcrypt-devel
libpng-devel
libtool-ltdl-devel
libxml2-devel
libXpm-devel
libc-client
libc-client-devel
libmcrypt-devel
libpng-devel
db4-devel

...And other prompted dependencies in the ./configure 
(always install the *-devel package too)

Download the PHP Source

$ wget http://ar2.php.net/get/php-5.6.10.tar.gz/from/this/mirror  

Unzip downloaded file and change to folder

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

Execute the configure command with the desired params (my example below)

./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 \ 
--with-mcrypt \  
--with-mhash \  
--with-curl \  
--with-gd \
--enable-gd-native-ttf \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--with-zlib-dir=/usr \
--with-xpm-dir=/usr \
--with-vpx-dir=/usr \
--with-freetype-dir=/usr \
--with-t1lib=/usr \
--with-libxml-dir=/usr \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \  
--enable-soap \
--with-xmlrpc \
--with-xsl \
--with-tidy=/usr \
--enable-pcntl \
--enable-sysvshm \
--enable-sysvmsg \
--enable-shmop

If you see any error when running this command, you are probably missing some dependency (maybe a dependency that I have not mentioned).

After run the configure command without errors

$ make && make install  

At this moment, PHP is already installed. To certify, use the command below:

$ php -v  

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

Copy php.ini to the correct directory

### If you're on a development server    
$ cp php.ini-development /etc/php.ini

### If you're on a production server
$ cp php.ini-production /etc/php.ini

Open Apache config file to edit

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

Add the following lines so that Apache interpret PHP (ignore if already have)

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

Restart Apache

$ service httpd restart
like image 124
jflizandro Avatar answered Sep 22 '26 17:09

jflizandro



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!