Page 1 of 1

OCI8 Problems

PostPosted: 17. October 2019 18:06
by ralplpcr
Hi all,

I've been banging my head for over a week trying to get OCI8 to activate on my Linux system. It was so nice & easy with the PHP 5.x series - just run sudo /opt/lampp/lampp oci8, point to the library, and it was done! However, since installing XAMPP 7.3.9, I simply haven't been able to get it working.

I am running Linux Mint 19.2 XFCE edition, and I've tried to get OCI working on XAMPP 7.1.1, 7.3.9, and 7.3.10. I've even completely reformatted & installed fresh to make sure that it isn't something in my particular configuration that's blocking the installation. It just doesn't work as configured in the installer package. It says that it "likely succeeded"... but it fails to load or show in phpinfo, and attempts to run a script using OCI fail when executing unknown command ociconnect.

I've searched online, and have found several guides to install OCI8 manually, but they all relate to a different pre-configured LAMP stack or a CLI-only interface. Nothing to help me troubleshoot or install OCI8 manually into XAMPP.

Can anyone here help provide some directions how I can activate/connect to the OCI8 service in XAMPP? This would be connecting to an external Oracle server. Appreciate any help you can provide - - thanks!

Re: OCI8 Problems

PostPosted: 19. October 2019 20:21
by ralplpcr
Just for kicks & giggles, I downloaded & installed Deepin Linux 15.11 today on a blank SSD. I then attempted to install XAMPP 7.3.10 from a fresh download. I had the same results. :( Following the instructions from, I saw exactly what was shown in the FAQ:
Code: Select all
How do I activate the OCI8/Oracle extension for PHP?

    To activate the OCI8/Oracle extension for PHP please execute the following command:

    sudo /opt/lampp/lampp oci8

    The following dialog will start:

    Please enter the path to your Oracle or Instant Client installation:


              installing symlinks...

              patching php.ini...

              OCI8 add-on activation likely successful.

              LAMPP: Stopping Apache with SSL...

              LAMPP: Starting Apache with SSL...

    The extension should now be active.

However, the extension was not active. Can anyone help? If I knew where XAMPP gets it's LIBRARY_PATH, LD_LIBRARY_PATH, and ORACLE_HOME environment variables, I may be able to manually point it to the correct instantclient. (I already know how to download the using PECL)

Re: OCI8 Problems

PostPosted: 26. October 2019 14:32
by ralplpcr
Wow, I must have picked a rather difficult subject! Just to follow up - I haven't had a lot of time this past week to mess with this, as I've had another project I needed to focus on. I'm not giving up, though.... still am hoping to figure out how to get OCI8 working on my Linux Mint 19.2 XFCE box. I'll keep checking in with the hope that someone can provide some guidance?

Re: OCI8 Problems

PostPosted: 26. October 2019 17:25
by Nobbie
ralplpcr wrote:Wow, I must have picked a rather difficult subject!

Yes of course. Because this forum is (by far) used by private people, running their PCs and their free software packages.

Oracle8 is a professional tool for professional companies, but this forum is not meant for professional companies. It is meant for all these private guys running their private PC. We cannot support companies here. I dont know even one guy who bought an Oracle license. Xampp users are going for MySQL/MariaDB. And not Oracle. Why should a Xampp user go for Oracle?

On the other hand, professional companies usually do NOT run Xampp, which is designed for home work and home development. Its a very very rare combination, running Xampp with Oracle8.

So, yes, its "Wow", there is nobody with any Oracle knowledge, neither any knowledge about running Oracle with Xampp. Sorry for that.

Re: OCI8 Problems

PostPosted: 26. October 2019 17:32
by Altrea
Well, I have running nearly a dozen of Oracle installations at my company. I even have coupled one or two of them with PHP years ago. So I maybe have some beginner DBA skills.

But none of them is or was running on Linux and the majority of them are driven by C++ or C# applications.
I cannot help at this topic in any way.

P.S. Oracle also releases a free express version of his database product, but I have no experience with that at all

Re: OCI8 Problems

PostPosted: 26. October 2019 17:58
by ralplpcr
Nobbie wrote:...Xampp users are going for MySQL/MariaDB. And not Oracle. Why should a Xampp user go for Oracle?

I develop web tools & applications for my company, which utilizes an Oracle database in production. In order to properly develop & test these tools, I need to be able to connect into this Oracle database from my test system. Xampp provides a quick & easy means of installing a functional LAMP stack with limited fuss and (at least with the PHP 5.x series & below) connect to Oracle as needed.

I don't have Oracle on my own system. I don't even have write access to Oracle at my company - - when I need to write/manipulate data with a database, I use Maria or MySQL. But having the ability to READ Oracle databases is important for me. I'll keep digging into it.... I'm sure it's possible: just need to figure out how Xampp populates all it's environment variables, and point it at the right library!

Thanks for your reply!

Altrea wrote:P.S. Oracle also releases a free express version of his database product, but I have no experience with that at all
I would be perfectly OK using an alternate means of connecting, as long as I could extract the results into a PHP script somehow. I'll take a look at the Oracle website & see if there's anything that jumps out. I've already got their "instantClient" installed.... but getting Xampp to recognize it has been a challenge.

Thanks for your response!

Re: OCI8 Problems

PostPosted: 31. October 2019 19:20
by ralplpcr
No luck yet. :( I've tried installing on a fresh Ubuntu VM, a Mint 19.2 Cinnamon VM, and a fresh Fedora 31 VM. Ubuntu & Mint both gave me the same results as before. Fedora wouldn't even install XAMPP - - I kept getting a "Floating Point Error" after trying to run the XAMPP installer? [To be fair, I don't normally use .RPM-based Linux..... so that could be my fault somehow?]

Still digging.....

Re: OCI8 Problems

PostPosted: 11. November 2019 19:31
by ralplpcr
I have some partial success getting OCI8 working with PHP7....unforutnately, it is only working via the CLI and not the web interface, however.

I utilized the instructions found @ as a base. I had to modify them in several places in order to better match the XAMPP paths & variables, but at least it's progress?

I started with a brand-new VM freshly installed with Linux Mint XFCE 19.2. Installed all the updates, & then downloaded XAMPP 7.3.11 for Linux. I installed it using the default settings, except I did uncheck the box to learn more about Bitnami. When it was finished, I started the Apache service and verified that it functioned.

  • At instruction 7a, I had to manually create the oracle-instantclient.conf file, as it did not exist.
  • At instruction 8a, it appears that the method to install using pecl has been altered. I needed to run
    Code: Select all
    sudo pecl channel-update
    and allow the update to complete before I could run
    Code: Select all
    sudo pecl install oci8

    as described.
  • Instruction 9b: this directory & file doesn't exist. Instead, updated /opt/lampp/etc/php.ini to add the "" extension.
  • Since the pecl install placed the file into /usr/lib/php/20170718, but it didn't exist in the XAMPP PHP extension directory, copy into /opt/lampp/lib/php/extensions/no-debug-non-ztf-20180731 and make readable to all
  • Instruction 10b: this directory & file doesn't exist. Instead, update /opt/lampp/bin/envvars to add export LD_LIBRARY_PATH="/opt/oracle/instantclient" & "export ORACLE_HOME="/opt/oracle/instantclient" at the bottom of the file.

Restart the server using "sudo /opt/lampp/lampp restart"

Using the simple "php connection example" as listed (renamed to 'test.php'), I am now able to connect to the Oracle database via the CLI:
Code: Select all
php '/opt/lampp/htdocs/test/test.php'
Oracle database connection online

However, attempting to do the same via XAMPP through a web browser still fails:
Code: Select all
Fatal Error: Uncaught Error: Call to undefined function oci_connect() in /opt/lampp/htdocs/test/test.php:5 Stack trace: #0 {main} thrown in /opt/lampp/htdocs/test/test.php on line 5

Effectively, this gets OCI8 working on a separate CLI instance of PHP & Apache. It's a step in the right direction, but I'm still digging to figure out why it won't work in the web interface of XAMPP..... any idea what I'm missing?

Re: OCI8 Problems [Worked Around]

PostPosted: 09. December 2019 20:12
by ralplpcr
While I have not been able to get OCI8 working in XAMPP yet, I have been able to get it working as part of a generic LAMP stack. :D It's not ideal for me, but it does work well enough to get me by. I'll document here the steps I took, in case anybody else needs such a function. (or maybe knows how to get the same type of paths in XAMPP updated so it'll work in XAMPP?)

Installation of the LAMP stack was pretty simple. I'm using Linux Mint 19.2 XCFE, which is Ubuntu-based and uses the Debian packaging system. To use a mostly pre-configured system, simply do the following:
Code: Select all
sudo apt update
sudo apt install tasksel
sudo apt install lamp-server

You can test & alter the configuration of the LAMP stack however you wish. At the time of this writing, this will install PHP 7.2 & MySQL 5.0.12. The default directory for HTML & PHP scripts is /var/www/html.

I installed PHPMyAdmin through my distro's software manager. It recognized the installed PHP & MySQL, and offered to associate the settings automatically.

Next, I took the following steps to get OCI8 working:

1. Download the Oracle Instant Client and SDK from Oracle website. (Need to login in Oracle page)
Files: &

2. Create a target folder for the instant client, and extract the files into it
Code: Select all
sudo mkdir /opt/oracle
sudo cp /home/ralplpcr/Downloads/instant*.* /opt/oracle/
cd /opt/oracle
sudo unzip
sudo unzip

3. Create symlinks to Instant client files
Code: Select all
sudo ln -s /opt/oracle/instantclient_12_2/ /opt/oracle/instantclient_12_2/
sudo ln -s /opt/oracle/instantclient_12_2/ /opt/oracle/instantclient_12_2/

4. Add folder to our ldconfig & update run-time bindings
Code: Select all
sudo su
echo /opt/oracle/instantclient_12_2 > /etc/

5. Install the necessary packages to build & compile the OCI8 packages from PECL (still in superuser mode)
Code: Select all
apt-get install php-dev php-pear build-essential libaio1
apt install php-dev
pecl channel-update
pecl install oci8

When you are prompted for the Instant Client location, enter the following:
Code: Select all

6. Tell PHP to load the OCI8 extension
Code: Select all
echo "extension" >> /etc/php/7.2/fpm/php.ini
echo "extension" >> /etc/php/7.2/cli/php.ini
echo "extension" >> /etc/php/7.2/apache2/php.ini

7. Add Apache environment variables:
Code: Select all
echo "export LD_LIBRARY_PATH=/opt/oracle/instantclient_12_2" >> /etc/apache2/envvars
echo "export ORACLE_HOME=/opt/oracle/instantclient_12_2" >> /etc/apache2/envvars
echo "LD_LIBRARY_PATH=/opt/oracle/instantclient_12_2:$LD_LIBRARY_PATH" >> /etc/environment

8. Restart Apache & check if OCI8 is loaded
Code: Select all
systemctl restart apache2
php -m | grep 'oci8'

If this returns OCI8, then you've succeeded!

9. Verify function works for web server
Create a simple phpinfo.php file in /var/www/html:
Code: Select all
<?php phpinfo(); ?>

Open a web browser and navigate to the server. (For me, LOCALHOST worked just fine) Open your phpinfo.php file, and search for oci8.
It should now have a section of it's own in phpinfo, and show as enabled.


I'm still hoping to eventually get this working in XAMPP... but at least I now this will be good enough to get me by.
If anyone here knows how to apply a similar operation to the XAMPP installation instead of a generic LAMPP stack, please feel free to chime in!