Oracle Database, or more commonly referred to only as Oracle, is a Relational Database Management System (RDBMS) type, which is a proprietary database from Oracle Corporation. The PHP programming language can use Oracle, but by default PHP on Ubuntu 18.04 is not yet available for Oracle driver, so you have to install it manually.
*0. Requirements*
Ubuntu 18.04 must be installed using Apache and PHP (7.2).
*1.Install Oracle Driver*
Download Oracle instantclient here. Then upload to the server.
1. instantclient-basic-linux.x64-12.2.0.1.0.zip 2. instantclient-sdk-linux.x64-12.2.0.1.0.zip
Extract files that have been uploaded on the server.
[INPUT]1 2 unzip instantclient-basic-linux.x64-12.2.0.1.0.zip unzip instantclient-sdk-linux.x64-12.2.0.1.0.zip
Create oracle folder.
[INPUT]1 mkdir /opt/oracle
Move and rename the instantclient folder.
[INPUT]1 mv instantclient_12_2 /opt/oracle/instantclient
Change folder ownership.
[INPUT]1 chown -R root:www-data /opt/oracle
Install dependencies needed to install OCI8 (Oracle Instant Client 8).
[INPUT]1 apt install php7.2-dev php-pear build-essential libaio1
Make a symbolic link.
[INPUT]1 2 ln -s /opt/oracle/instantclient/libclntsh.so.12.1 /opt/oracle/instantclient/libclntsh.so ln -s /opt/oracle/instantclient/libocci.so.12.1 /opt/oracle/instantclient/libocci.so
Add an instant client to ldconfig.
[INPUT]1 echo /opt/oracle/instantclient > /etc/ld.so.conf.d/oracle-instantclient.conf
Update Dynamic Linker Run-Time Bindings
[INPUT]1 ldconfig
Install oci8.
[INPUT]1 pecl install oci8
Showing questions
[INPUT]1 Please provide the path to the ORACLE_HOME directory. Use ‘instantclient,/path/to/instant/client/lib’ if you’re compiling with Oracle Instant Client [autodetect] :
Answer with
[INPUT]1 instantclient,/opt/oracle/instantclient
Add OCI8 to cli php config.
[INPUT]1 echo “extension = oci8.so” >> /etc/php/7.2/cli/php.ini
Add OCI8 to Apache PHP Config.
[INPUT]1 echo “extension = oci8.so” >> /etc/php/7.2/apache2/php.ini
Set environement variables for cli (The server must be restarted)
[INPUT]1 2 echo “LD_LIBRARY_PATH=\”/opt/oracle/instantclient\”” >> /etc/environment echo “ORACLE_HOME=\”/opt/oracle/instantclient\”” >> /etc/environment
Set environement variables for apache.
[INPUT]1 2 echo “export LD_LIBRARY_PATH=\”/opt/oracle/instantclient\”” >> /etc/apache2/envvars echo “export ORACLE_HOME=\”/opt/oracle/instantclient\”” >> /etc/apache2/envvars
Restart apache
[INPUT]1 systemctl restart apache2
*2.Testing*
Create info.php file.
[INPUT]1 echo “” > /var/www/html/info.php
Browse http://IP-SERVER/info.php, find oci8.
PHP Info – oci8
Good luck ð