Talk: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.

Aside from the Encoding problems, the link provided in the article puts the pickle in the jar.

Encoding Woes

Using the Zend provided packaged install of Apache+PHP, I found it was needed to hack a bit to get the environment with the correct $NLS_LANG. (This can be done by editing the provided {ZENDHOME}/apache2/bin/apachectl, or in an rc script - ymmv if not using the Zend packaged PHP5+Apache2).

Best to set NLS_LANG=$($ORACLE_HOME/bin/, so your web server just takes it from whatever Oracle decides it should be. In my locale the default happens to be "AMERICAN_AMERICA.AL32UTF8". Bryan Cribbs 22:05, 28 January 2007 (CST)

Full Account of the Process

I have just completed setting up a Moodle-on-Oracle integration (including having Moodle's databases populated by the external database via a 'push' mechanism as opposed to Moodle's 'pull' mechanism).

I have created an account of the process (there were lots of snags and issues along the way) and am currently hosting it on my own personal server at home. If someone thinks it might be useful (to include on this docs page) then I have no qualms with anyone wikifying it and putting it onto the page (but I must admit, I'm terrible at wiki syntax).

The easy way

is to use the free Zend for Oracle package (including Apache2 and Oracle client components). You can avoid creating tsnnames.ora etc. by simply putting the whole DB connect string in the moodle setup database field (leave server field free).

Zend for Oracle

In my case a connect string like // in the database field worked. Depending on your local DB setup you may not need the part after MYDB.

If you need to set environment variables for apache startup the best place is in the file envvars. In the Zend distribution this file is in apache2/bin under the Zend installl.

If things do not work set


and NLS_LANG (try american_america.AL32UTF8 if you do not know what to set here).

Don't forget to export LD_LIBRARY_PATH (and other env variables)

I would prefer to set the NLS_LANG value in the php connect code, not environment (see example below).

The following php code snippet returns the Oracle error message if you want to do a simple connection test. The moodle install routine unfortunately does not.

Georg Anker


if (oci_connect("myuser","mypasswd","//","AL16UTF8")) {
       echo "Connected";

} else {

       echo "NOT Connected";
       $err = oci_error();
       echo htmlentities($err['message']);