This tutorial is for Ubuntu Server 24.04 with PHP 8.3.
I've compile all the steps into an installer, check it here https://github.com/syahzul/oci-installer-ubuntu
Install required dependencies.
sudo apt update
sudo apt install -y libaio1t64 unzip php8.3-devCreate a symlink for libaio (Ubuntu 24.04 uses libaio.so.1t64 but Oracle Instant Client looks for libaio.so.1).
sudo ln -s /usr/lib/x86_64-linux-gnu/libaio.so.1t64 /usr/lib/x86_64-linux-gnu/libaio.so.1Visit Oracle Instant Client website and download the following files:
Create a new folder to store Oracle Instant Client zip files on your server.
sudo mkdir /opt/oracleUpload the downloaded files to this folder. Now we need to extract the files.
cd /opt/oracle
unzip instantclient-basic-linux.x64-23.26.0.0.0.zip
unzip instantclient-sdk-linux.x64-23.26.0.0.0.zipAdd the folder to our ldconfig.
sudo -s
echo /opt/oracle/instantclient_23_26 > /etc/ld.so.conf.d/oracle-instantclient.confRun the command below to update the Dynamic Linker Run-Time Bindings
ldconfigInstall OCI8 using PECL.
echo instantclient,/opt/oracle/instantclient_23_26 | sudo pecl install oci8Enable the OCI8 extension by creating an ini file for PHP 8.3.
echo "extension=oci8.so" | sudo tee /etc/php/8.3/mods-available/oci8.ini
sudo phpenmod -v 8.3 oci8Restart PHP-FPM service.
sudo systemctl restart php8.3-fpm.serviceFrom your Terminal, check if the module is loaded:
php -i | grep 'oci8'If it returns oci8, it works!
Or, create a PHP file and add the code below:
<?php
if (function_exists('oci_connect')) {
echo 'OCI8 is working!';
}
else {
echo 'Whoopss...not working!';
}Test it on your web browser.