Activate Oracle on XAMPP for Windows

PHPWith the default installation of XAMPP for Windows, we don’t get PHP Oracle connectivity enabled. This can be enabled easily when you need to connect to a Oracle Database from your PHP application/script. PHP has got the OCI8 extension, which provides Oracle connectivity to PHP application, and OCI8 uses Oracle Instant Client Package to get Oracle specific functions.
Oracle Database
I had the need to connect to a Oracle Database from a PHP script in one of my recent projects, the following is what I did to enable Oracle connectivity in XAMPP for Windows.

  1. In your XAMPP Start Page, go to phpinfo, look for string oci8. If string found it indicate that connection to oracle is available, otherwise to activate connection do the following steps:
  2. Open the currently used php.ini file by looking at the phpinfo, from the XAMPP folder.
  3. Find string ;extension=php_oci8.dll. Remove the semicolon (;) ahead of the string to activate the oracle extension.
  4. Save the php.ini file.
  5. Download the “Instant Client Package – Basic” for Windows from the OTN Instant Client page. Unzip it to c:\instantclient_11_1
  6. Edit the PATH environment setting and add c:\instantclient_11_1 before any other Oracle directories. For example, on Windows XP, follow Start -> Control Panel -> System -> Advanced -> Environment Variables and edit PATH in the System variables list.
  7. Set desired Oracle globalization language environment variables such as NLS_LANG. If nothing is set, a default local environment will be assumed. See An Overview on Globalizing Oracle PHP Applications for more details.
  8. Unset Oracle variables such as ORACLE_HOME and ORACLE_SID, which are unnecessary with Instant Client (if they are set previously).
  9. Restart XAMPP (or Start if its not already started).
  10. To make sure that connection to oracle database has successfully activated, go to phpinfo. Find string: oci8. If found, then XAMPP can now communicate with Oracle Database.

The steps to do the same in a Linux box are almost similar, except there you will use the Linux versions of the packages and setting PATH variables would be different.

You can ping me back with a comment if you run into any issues, I might be able to help you or I can learn from you.

Reference:

8 thoughts on “Activate Oracle on XAMPP for Windows”

  1. Something is not quite right. I got the error:

    Warning: ocilogon() [function.ocilogon]: OCIEnvNlsCreate() failed. There is something wrong with your system – please check that PATH includes the directory with Oracle Instant Client libraries

    I have the PATH variable set up with C:\instantclient_11_1. Any thoughts?

  2. Doug,

    I’m not currently having a suitable system to work on this as I have moved on from my earlier profession.

    But as far as I remember, this worked for me and few of my friends back them, I’m not sure what has changed lately….

  3. Qual a versão do xampp que realmente roda a conectividade do oracle, ja tentei XAMPP 1.7.1 php 5.2.9 e não roda, a versão XAMPP 1.7.3 php 5.3.1 roda, porem dá erro em minha página devido funcoes que nao existe mais nesta versão.

    Portuguese to English translation:
    Which version of xampp that actually runs the connectivity of Oracle, I tried XAMPP 1.7.1 and php 5.2.9 does not run the XAMPP version 1.7.3 php 5.3.1 runs, but gives error on my page that does not exist because functions more in this version.

    1. I do not remember my XAMPP version (I did this almost a year ago, in a different country, for a different job 🙂 ). So I am unable to check this with the newer versions of the software.

      I have a friend who is still using this, and it seems to be working for him. It should normally work when you install the Oracle Instant Client Package, do the correct modification to php.ini file and add the Environment Variables.

  4. hello, I was able to connect but encountered third error. Any suggestions???

    Warning: oci_connect() [function.oci-connect]: ORA-12541: TNS:no listener in c:\xampp

Leave a Reply