Difference between revisions of "Installing Oracle for PHP"

Jump to: navigation, search

Note: You are currently viewing documentation for Moodle 1.9. Up-to-date documentation for the latest stable version is available here: Installing Oracle for PHP.

(Install Moodle)
(Install Moodle)
Line 43: Line 43:
=== Install Moodle ===
=== Install Moodle ===
On the database setup page:<br />
On the database setup page:<br />
Driver: Oracle oci8 ("oci8po" for a 1.9.x install and "oci" for a 2.0.x install)<br />
Driver: Oracle oci8 (in the config file it should read "oci8po" for a 1.9.x install and "oci" for a 2.0.x install)<br />
Host: empty the field<br />
Host: empty the field<br />
Database: //localhost:1521/XE<br />
Database: //localhost:1521/XE<br />

Latest revision as of 08:58, 2 February 2011

Important Note: Don't forget to enable this variable in your php.ini (or .htaccess) file:

(else, all your data will be escaped following MySQL rules, that are incorrect for Oracle)

   magic_quotes_sybase = On

Broken versions of OCI8 driver

PHP v5.2.4 (and perhaps v5.2.3 as well) have shipped with a bug in the OCI8 driver that leaks statement handles. The version of the OCI8 driver with the bug is v1.2.4. Possible workarounds:

  • Upgrade to PHP v5.2.5 or later
  • Downgrade to PHP v5.2.1 (reported to work)
  • Downgrade only the oci8 driver to the one included in PHP 5.2.1 (it worked for us -- iarenaza)
  • If you are on linux and/or can compile PECL extensions, install an older OCI8 driver (v1.2.3 seems to work) from the PECL repository http://pecl.php.net/package/oci8

More information at

Installing Moodle on Windows with Oracle Express Edition


This section explains how to install Moodle with Oracle Express Edition on Windows. I'm using it for debugging purpose. It's definitively not a production environment. The goal is to setup easily and quickly a Moodle/Windows/Oracle environment.

Install Oracle

Download Oracle Express Edition on Oracle web site.
You will also need the Instant client from here (free account sign up needed). Copy everything from the unzipped folder into apache/bin.
Install both.
Access to the oracle console ( Login: SYS Password: the_one_you_entered_during_the_installation
Create a new user and give it all rights (including DBA).
Note: Oracle Express Edition 10g is limited at one database called 'XE'.

Set up your oracle extension

This document does not explain how to setup apache/php for Oracle. You can have more information on Oracle Documentation. On my own machine I used my WAMP installation (Wampserver 2.0) which allowed me to activate all oracle extensions in few clicks (php_oci8, php_oracle, php_pdo_oci, php_pdo_oci8).

Install Moodle

On the database setup page:
Driver: Oracle oci8 (in the config file it should read "oci8po" for a 1.9.x install and "oci" for a 2.0.x install)
Host: empty the field
Database: //localhost:1521/XE
User: the user that you created
Password: the password you gave to the user

Configure Apache

If you're running Moodle on Oracle with Apache on Linux, you might have issues with PHP being able to see the system environment variables. To resolve this, you can edit /etc/sysconfig/apache2 and add the following lines to the bottom:

LD_LIBRARY_PATH=/opt/oracle/instantclient_11_2# Set LANG Variables for UTF-8

Also need to add those two lines to ~/.bashrc so that the PHP command-line client can see it too.

Related links