This is the ad hoc tutorial on how to enable PHP PDO for ORACLE 12C / 11G. First, we will download and install necessary files and rpm packages. Then we will make the needed system configurations. Next we’ll install the Oracle pdo package, create the php configuration file and test the connectivity with PDO to ORACLE server.
Below content is complementary to the video tutorial above.
Download and install necessary files and packages:
1. Get your Oracle version using SQL query:
2. Download rpm basic and devel packages corresponding your version from http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html.
3. Copy downloaded basic and devel rpm packages to your server.
rpm -ivh oracle-instantclient12.2-basic-12.2.0.1.0-1.x86_64.rpm
rpm -ivh oracle-instantclient12.2-devel-12.2.0.1.0-1.x86_64.rpm
rm -f oracle*.rpm
Make the necessary configurations:
oracle_version="12.2"
ln -s /usr/include/oracle/$oracle_version/client64 /usr/include/oracle/$oracle_version/client
ln -s /usr/lib/oracle/$oracle_version/client64 /usr/lib/oracle/$oracle_version/client
echo "export LD_LIBRARY_PATH=/usr/lib/oracle/$oracle_version/client64/lib" > /etc/profile.d/oracle.sh
source /etc/profile.d/oracle.sh
Install the PHP Oracle pdo packages:
php_version="7.2.6"
wget http://be.php.net/distributions/php-$php_version.tar.gz
tar xfvz php-$php_version.tar.gz
cd php-$php_version/ext/pdo_oci
./configure --with-pdo-oci=instantclient,/usr/lib/oracle/$oracle_version/client64/lib,$oracle_version
make install
cd ~
rm -Rf php-$php_version*
Create the PHP configuration file:
php -i | grep oci
Restart the necessary services:
Test the installed ORACLE PDO (additionally, see the output of phpinfo() for PDO OCI section):
Related resources: