OCI8 Problems

Problems with the Linux version of XAMPP, questions, comments, and anything related.

OCI8 Problems

Postby ralplpcr » 17. October 2019 18:06

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!
Posts: 13
Joined: 17. October 2019 17:54
XAMPP version: 7.3.9
Operating System: Linux

Re: OCI8 Problems

Postby ralplpcr » 19. October 2019 20:21

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 https://www.apachefriends.org/faq_linux.html, 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 oci8.so using PECL)
Posts: 13
Joined: 17. October 2019 17:54
XAMPP version: 7.3.9
Operating System: Linux

Re: OCI8 Problems

Postby ralplpcr » 26. October 2019 14:32

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?
Posts: 13
Joined: 17. October 2019 17:54
XAMPP version: 7.3.9
Operating System: Linux

Re: OCI8 Problems

Postby Nobbie » 26. October 2019 17:25

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.
Posts: 11769
Joined: 09. March 2008 13:04

Re: OCI8 Problems

Postby Altrea » 26. October 2019 17:32

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
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
AF Moderator
Posts: 10427
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: OCI8 Problems

Postby ralplpcr » 26. October 2019 17:58

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!
Posts: 13
Joined: 17. October 2019 17:54
XAMPP version: 7.3.9
Operating System: Linux

Re: OCI8 Problems

Postby ralplpcr » 31. October 2019 19:20

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.....
Posts: 13
Joined: 17. October 2019 17:54
XAMPP version: 7.3.9
Operating System: Linux

Re: OCI8 Problems

Postby ralplpcr » 11. November 2019 19:31

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 @ https://serverfault.com/questions/911475/howto-install-oracle-oci8-instantclient-on-ubuntu-18-04 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 pecl.php.net
    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 "oci8.so" extension.
  • Since the pecl install placed the oci8.so file into /usr/lib/php/20170718, but it didn't exist in the XAMPP PHP extension directory, copy oci8.so 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?
Posts: 13
Joined: 17. October 2019 17:54
XAMPP version: 7.3.9
Operating System: Linux

Re: OCI8 Problems [Worked Around]

Postby ralplpcr » 09. December 2019 20:12

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: instantclient-basic-linux.x64- & instantclient-sdk-linux.x64-

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 instantclient-basic-linux.x64-
sudo unzip instantclient-sdk-linux.x64-

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

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

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.php.net
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 =oci8.so" >> /etc/php/7.2/fpm/php.ini
echo "extension =oci8.so" >> /etc/php/7.2/cli/php.ini
echo "extension =oci8.so" >> /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!
Posts: 13
Joined: 17. October 2019 17:54
XAMPP version: 7.3.9
Operating System: Linux

Re: OCI8 Problems [SOLVED]

Postby ralplpcr » 17. July 2020 20:01

Holy moly, I got it working! It took an insanely long time to piece together, but it's finally working! :D

I took some direction from https://medium.com/@arisandyrico/oracle-in-linux-xampp-aaefae236bd4, but couldn't get it working until I made a few minor modifications. I'll document what finally did it for me - - hopefully, it'll resolve the issue if anyone else has need of it as well?

For this test, I used a fresh install of Linux Mint 18.1 XCFE, fully updated.

1. Install the XAMPP package as usual. For the purpose of this test, I used xampp-linux-x64-7.4.8-0-installer.run

2. Install the oracle-instantclient12.2-basic- and oracle-instantclient12.2-devel- packages into /usr/lib/oracle/. I basically just followed step 1 of the above-linked blog post, after installing alien, and downloading the .RPM packages.

3. I wasn't sure if this step was needed or not, but I did it anyhow - - this is step #2 of the above-linked blog post. I basically copy/pasted everything between the "---------------------" to the end of the ~/.bashrc file. I then exited the terminal, and re-launched it.
Code: Select all

I have an issues that my path always getting reset each time I open new terminal. If that happens to you then edit file with this command.

    nano ~/.bashrc

then add this
    # enable programmable completion features (you don’t need to enable
    # this, if it’s already enabled in /etc/bash.bashrc and /etc/profile
    # sources /etc/bash.bashrc).
    if ! shopt -oq posix; then
    if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
    elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
    #*code above just notify if you are in correct .bashrc

    # MOD <=============insert it to add new variable
    # Additional PATH
    export ORACLE_HOME=/usr/lib/oracle/12.2/client64
    export LD_LIBRARY_PATH=/usr/lib/oracle/12.2/client64/lib
    # lampp Path
    export PATH=$PATH:/opt/lampp/bin

4. Run sudo apt install php-pear

5. Download oci8-2-2.0.tgz from https://pecl.php.net/package/oci8

6. Extract it using tar xzvf oci8.tgz

7. Recursively update the permissions of the extracted oci8-2.2.0 folder to allow full read/write access.

8. Recursively update the permissions of the /opt/lampp directory to allow full read/write access.

9. Copy/paste the oci8-2.2.0 folder into the /opt/lampp directory

10. Open (or switch to) the /opt/lampp/oci8-2.2.0 directory in your terminal

11. Enter which phpize, and verify that the return value is /opt/lampp/bin/phpize

12. Run phpize

13. Run ./configure --with-oci8=shared,instantclient,/usr/lib/oracle/12.2/client64/lib (Note- this will fail if you didn't update the permissions above!)

14. Run make all install

15. Run sudo /opt/lampp/lampp oci8
When this runs, just press ENTER when prompted for the path to Instant Client!

16. Recursively update the permissions of the /opt/lampp directory to set read-only for all but root.
You can then go in & modify individual subdirectories to allow write access as needed. (such as /opt/lampp/htdocs)

Cross your fingers, restart XAMPP... and hopefully you'll now see OCI8 in your phpinfo() output!

Image https://imgur.com/a/KeJuk3J

And just to verify, a simple test connection to Oracle *does* now function in XAMPP. :D
Image https://imgur.com/a/SWbwJvh

I don't quite understand why the built-in ./lampp oci8 program linking to the wrong instant client instead of the newly-installed actually works.... but it did? And as far as I'm concerned, that's a win in my book!

I was able to uninstall XAMPP and then re-install, and it stopped working. Repeating steps 6-16 were successful in re-enabling OCI8, so I suspect it has something to do with the oci8-2-2.0.tgz being copied & compiled directly in the /opt/lampp directory before the built-in /opt/lampp/lampp oci8 program will work? I haven't traced exactly what that may be.... but since it's working for me this way, I'll probably just accept it as-is.
Posts: 13
Joined: 17. October 2019 17:54
XAMPP version: 7.3.9
Operating System: Linux

Re: OCI8 Problems [UPDATE]

Postby ralplpcr » 18. July 2020 22:59

Attempted this procedure on Mint 20 XFCE - it failed. :(

Tried it next on Mint 19.2 XFCE. It failed at first... but I finally got it working as well.
I'm not sure what's different between 18.1 and 19.2 in particular that would make it necessary, but I ended up having to copy/replace the entire contents of the /usr/lib/oracle/12.2/client64/lib directory into XAMPP's default /opt/lampp/lib/instantclient- directory.

After re-running sudo /opt/lampp/lampp oci8 and sudo /opt/lampp/lampp restart, it once again started working.

I haven't yet tried this replacement procedure on Mint 20.... but at least it's now possible to make it work on 18.1 and 19.2? :)
Posts: 13
Joined: 17. October 2019 17:54
XAMPP version: 7.3.9
Operating System: Linux

Re: OCI8 Problems [Re-SOLVED]

Postby ralplpcr » 20. July 2020 13:17

It is now working on Mint20 XFCE. :D

I'm still not sure of the exact reason, but it seems that something has changed between the Mint 18 series & Mint 19/20 releases that requires that extra step of replacing the default instantclient directory. I'll document the steps here - - the rest of the procedure is the same. Just insert this step into the procedure above as numbered, and it should work for you:

14.5 - Copy/paste the contents of /usr/lib/oracle/12.2/client64/lib directory into XAMPP's default /opt/lampp/lib/instantclient- directory, overwriting the existing files.
I did *NOT* delete any existing files - - just copy/overwrite.

I also discovered that for steps 7 & 8, I could also just set my own user to have read/write access instead of the writable to the world. This may be safer, since it avoids messing up any other permissions that may have been put in place.

All is working - I just hope it's not another struggle like this when PHP 8 comes out!
Image - https://imgur.com/8DEtbPd
Posts: 13
Joined: 17. October 2019 17:54
XAMPP version: 7.3.9
Operating System: Linux

Return to XAMPP for Linux

Who is online

Users browsing this forum: No registered users and 12 guests