Friday, July 16, 2010

Ubuntu install Oracle MOD_OWA



Recently I tried to install MOD_OWA on a Ubuntu Linux machine running a Oracle 11G database. MOD_OWA if the opensource alternative for Oracle mod PL/SQL and is providing a bridge between your Apache webserver and your oracle database. In your database you can develop code to generate HTML documents which are send via your webserver to the client requesting it.


The original intention was to install mod PL/SQL however due to the fact this is more demanding on your machine resources and I only needed it on my laptop to do some coding during commuting between home, work and customers I decided to install MOD_OWA instead as it is covering most of the things I need and the code developed on MOD_OWA is portable for most parts to a MOD PL/SQL installation.


Oracle is running a great guide on the oss.oracle.com website on how to install and use MOD_OWA on a linux installation. After my first failed attempt to install it I followed the guide from Doug McMahon step by step. Even after this I still received a ORA-01804 error when I tried to request any page via MOD_OWA. After consulting with Doug we came to the conclusion that it most likely had something to do with the settings of a $ORACLE_HOME variable.


Checking the $ORACLE_HOME variable for the user running Oracle and the user running Apache resulted in a conclusion that it was set correctly for those users. However, as it turns out Apache is ahving some issues with system variables set for the user running Apache and passing those variables to the child processes. One can see the error clearly when you do a strace (strace - trace system calls and signals) on the Apache processes and request the page that is giving you the error.


//-----------------------------------------------------------------------------------------------------------------
7910 lstat64("/var/tmp/oradiag_jolouwer/diag/clients/user_jolouwer/host_428099999_76/alert/log.xml", {st_mode=S_IFREG0640, st_size=3744, ...}) = 0
7910 stat64("/var/tmp/oradiag_jolouwer/diag/clients/user_jolouwer/host_428099999_76/alert/log.xml", {st_mode=S_IFREG0640, st_size=3744, ...}) = 0
7910 gettimeofday({1273129673, 750457}, NULL) = 0
7910 lstat64("/var/tmp/oradiag_jolouwer/diag/clients/user_jolouwer/host_428099999_76/alert/log.xml", {st_mode=S_IFREG0640, st_size=3744, ...}) = 0
7910 open("/var/tmp/oradiag_jolouwer/diag/clients/user_jolouwer/host_428099999_76/alert/log.xml", O_WRONLYO_CREATO_APPENDO_LARGEFILE, 0660) = 11
7910 write(11, "

In this part of the tracefile you will see on the last line a write statement including a part of a string "Unable to find environment varia". Above 2 files are mentioned. When one checks the log.xml file you will see a entry similar as the one below:



Unable to find environment variable: ORACLE_HOME



This is already telling you that the issue might resides in the $ORACLE_HOME settings even if you already checked this is set correctly for the users running Oracle and Apache. The sqlnet.log file will have a entry as the one below:


Thu May 06 16:43:38 2010

Unable to find environment variable: ORACLE_HOME


It turns out that when you run this combination in Apache you have to make a entry in the file /etc/apache2/envvars . The file wil state in its comments "Since there is no sane way to get the parsed apache2 config in scripts, some settings are defined via environment variables and then used in apache2ctl, /etc/init.d/apache2, /etc/logrotate.d/apache2, etc." So we know some issues might be present when it comes to parsing env variables. So if you add your Oracle env settings in this file and stop/start Apache you will notice that the problem is resolved.

I added the following:
export ORACLE_HOME=/u01/app/jolouwer/product/11.2.0/dbhome_1

export ORACLE_BASE=/u01/app/jolouwer

export ORACLE_SID=orcl

export ORACLE_UNQNAME=orcl


According to Doug he did not find this issue on any other system than the Ubuntu setup I used with a Oracle 11G Release 2. However, if you ever encounter this error when you setup MOD_OWA on a Linux box you might want to check your /etc/apache2/envvars file and try to add your ORACLE_HOME, ORACLE_BASE, ORACLE_SID and ORACLE_UNQNAME to this file.

Post a Comment