Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Buck's avatar
Level 5

Installing Oracle OCI8 PHP 8.0 Extension on Laravel Forge

Hello everyone,

PHP Version: 8.0, Oracle Database Version: 12c, Provider: Digital Ocean

I've been trying to install Oracle Instant Client and oic8 extension on Laravel Forge for a day and still haven't got any luck. Does Laravel Forge allow to install additional PHP extension?

Has anyone successfully installed the Oracle OCI8 PHP extension on a Laravel Forge server? If so, could you please share the steps you followed or any resources you found helpful?

Additionally, I would appreciate hearing about your experiences using the OCI8 extension with Laravel Forge. Have you encountered any issues or limitations that I should be aware of?

Thank you in advance for your help and insights.

0 likes
5 replies
LaryAI's avatar
Level 58

Installing the Oracle OCI8 PHP extension on a Laravel Forge server is possible, but it requires a few steps since it's not a standard PHP extension that can be installed with a simple command. Here's a step-by-step guide to help you through the process:

  1. Install Oracle Instant Client

    • First, you need to download the Oracle Instant Client from the Oracle website. Choose the version that matches your Oracle Database and operating system.
    • Upload the downloaded files to your server, or use wget or curl to download them directly to the server.
    • Install the basic and SDK packages using alien if you are on a Debian-based system or rpm if you are on a RedHat-based system.
  2. Set Environment Variables

    • Set the LD_LIBRARY_PATH environment variable to point to the location of the Oracle Instant Client libraries.
    • Update the ORACLE_HOME environment variable to the directory where you installed the Oracle Instant Client.
  3. Install the OCI8 PHP Extension

    • Install the necessary development tools and PHP development packages if they are not already installed.
    • Use pecl to install the OCI8 extension. You might need to specify the path to the Oracle Instant Client if pecl does not find it automatically.
  4. Configure PHP

    • After the installation is complete, you need to add the extension to your php.ini file. This can be done by creating a new .ini file in the conf.d directory.
    • Restart PHP-FPM to apply the changes.

Here's a more detailed walkthrough with commands:

# Install Oracle Instant Client
cd /tmp
wget <oracle-instantclient-download-url>
unzip instantclient-basic-linux.x64-12.1.0.2.0.zip
unzip instantclient-sdk-linux.x64-12.1.0.2.0.zip
sudo mkdir -p /opt/oracle
sudo mv instantclient_12_1 /opt/oracle/

# Set environment variables
echo 'export LD_LIBRARY_PATH="/opt/oracle/instantclient_12_1:$LD_LIBRARY_PATH"' | sudo tee -a /etc/environment
echo 'export ORACLE_HOME="/opt/oracle/instantclient_12_1"' | sudo tee -a /etc/environment
source /etc/environment

# Install development tools and PHP development packages
sudo apt-get update
sudo apt-get install -y build-essential php8.0-dev

# Install OCI8
sudo pecl install oci8

# When asked for the path to the Oracle Instant Client, input:
instantclient,/opt/oracle/instantclient_12_1

# Configure PHP
echo "extension=oci8.so" | sudo tee /etc/php/8.0/cli/conf.d/20-oci8.ini
echo "extension=oci8.so" | sudo tee /etc/php/8.0/fpm/conf.d/20-oci8.ini

# Restart PHP-FPM
sudo service php8.0-fpm restart

Please replace <oracle-instantclient-download-url> with the actual URL to the Oracle Instant Client zip files.

Keep in mind that the paths and version numbers may vary depending on the specific versions of the Oracle Instant Client and PHP you are using. Adjust the commands accordingly.

As for experiences and limitations, it's important to note that the Oracle OCI8 extension can be sensitive to version mismatches between the PHP extension and the Oracle Instant Client, so ensure they are compatible. Additionally, keep an eye on the Laravel Forge release notes and documentation for any updates or changes that might affect the installation process.

Tray2's avatar

I would start by asking, do you really need to run a Oracle Database?

Buck's avatar
Level 5

@Tray2 Yes, need. My company is using Oracle as a main database for all projects.

Please or to participate in this conversation.