Friday, May 18, 2012

configure oracle application express - oracle 11g

This document is mainly for configure oracle application express on oracle database installation version 11.2.0.2. It also includes some problems I met and their solutions. Hope it will be useful for others.

1. apex is installed defaultly as database installaion.
you can check it with below methods.
select username from dba_users where username like 'APEX%'
sys@TEST.corvus> select username from dba_users where username like 'APEX%';
USERNAME
------------------------------
APEX_PUBLIC_USER
APEX_030200
sys@TEST.corvus> select comp_id, comp_name, version, status from dba_registry where comp_id='APEX';
COMP_ID                        COMP_NAME                                VERSION                        STATUS
------------------------------ ---------------------------------------- ------------------------------ --------------------
APEX                           Oracle Application Express               3.2.1.00.12                    VALID

2. determin the architecture option.
Starting from 11g, there are 3 architectures to configure apex access: oracle applicaiton express listener, HTTP server with mod_plsql and embeded plsql gatway (EPG).
I configured HTTP Server first and EPG later. both can be configured to run at the same time on same server.

the easiest way is to EPG option.

3. configure APEX with HTTP server and mod_plsql architecture
3.1 configure apex on oracle database installation.
cd $ORACLE_HOME/Apex/bin
sqlplus / as sysdba
sqlplus > @apxchpwd   # change admin password
sqlplus > alter user apex_public_user account unlock
sqlplus > password apex_public_user
3.2 download oracle http server
#current it is available from version 11.2.0.1 as oracle fussion medtier.
http://www.oracle.com/technetwork/database/enterprise-edition/downloads/112010-linx8664soft-100572.html

3.3 install http server
./runInstaller     # install software only

3.4 configure http server
WebTier_ORAcLE_OME/bin/config.sh #don't select "associate to a domain' if you don't have a domain setup

3.5 load the mod_plsql module
vi WebTier_ORAcLE_OME/instances/instance1/config/OHS/ohs1/httpd.conf
add
   LoadModule plsql_module "${ORACLE_HOME}/ohs/modules/mod_plsql.so" 
   include /u01/app/oracle/product/11.1.1/ofm/Oracle_WT1/ohs/conf/mod_plsql/*.conf

3.6 copy images
cp -rf $ORACLE_HOME/apex/image $ORACLE_HTTPSERVER_HOME/ohs

3.7 configure dads.conf file
vi /u01/app/oracle/product/11.1.1/ofm/Oracle_WT1/ohs/conf/mod_plsql/dads.conf
add
Alias   /i/               "/u01/app/oracle/product/4.0.2/apex/images/" 
AddType text/xml          xbl 
AddType text/x-component  htc 
   
<Location /pls/apex> 
Order                          deny,allow 
PlsqlDocumentPath              docs 
AllowOverride                  None 
PlsqlDocumentProcedure         wwv_flow_file_manager.process_download 
PlsqlDatabaseConnectString     localhost:1521:XE ServiceNameFormat 
PlsqlNLSLanguage               AMERICAN_AMERICA.AL32UTF8 
PlsqlAuthenticationMode        Basic 
SetHandler                     pls_handler 
PlsqlDocumentTablename         wwv_flow_file_objects$ 
PlsqlDatabaseUsername          APEX_PUBLIC_USER 
PlsqlDefaultPage               apex 
PlsqlDatabasePassword          parsingschemapasswd 
PlsqlRequestValidationFunction wwv_flow_epg_include_modules.authorize 
Allow from all 
</Location>

3.8 stop and start http server
/u01/app/oracle/product/11.1.1/ofm/Oracle_WT1/instances/instance1/bin/opmnctl stopproc ias-component=ohs1
/u01/app/oracle/product/11.1.1/ofm/Oracle_WT1/instances/instance1/bin/opmnctl startproc ias-component=ohs1

3.9 open http port
vi /etc/sysconfig/iptables
add
-A INPUT -m state --state NEW -m tcp -p tcp --dport 7777 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 4443 -j ACCEPT
port 777 for http
port 443 for https

3.10 access apex
normal login
https://hostname:4443/pls/apex
http://hostname:7777/pls/apex
admin login
https://hostname:4443/pls/apex/apex_admin
http://hostname:7777/pls/apex/apex_admin

4. configure EPG
EPG use XDB associated HTTP server from oracle database installation so that you don't need download OHS seperately with installation and configuration.

4.1 configue apex
run as sysdba
sql> @?/apex/apxconf


      PORT
----------
      8080
Enter values below for the XDB HTTP listener port and the password for the Application Express ADMIN user.
Default values are in brackets [ ].
Press Enter to accept the default value.

Enter a password for the ADMIN user              []
Enter a port for the XDB HTTP listener [      8080]
...changing HTTP Port
PL/SQL procedure successfully completed.

PL/SQL procedure successfully completed.

Session altered.
...changing password for ADMIN
PL/SQL procedure successfully completed.

Commit complete.

4.2 unlock anonymous user
sql> alter user anonymous account unlock;

you will find the account is expired. if you don't want to login for XML DB funciton, leave it expired. otherwise you might get problem as I got. which make EPG configuration complex.

4.3 check if HTTP server up
sql> select dbms_xdb.gethttpport() from dual;

if it retruns 0, it is down. Then bring it up.

sql> exec dbms_xdb.sethttpport(8080);

if it returns 8080, it is up.

4.5 open port for apex
vi /etc/sysconfig/iptables
add
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
4.4 access apex
normal login
http://hostname:8080/apex
admin login
http://hostname:8080/apex/apex_admin

4.5 check epg status
sql>@?/rdbms/admin/epgstat
+--------------------------------------+
| XDB protocol ports:                  |
|  XDB is listening for the protocol   |
|  when the protocol port is non-zero. |
+--------------------------------------+
HTTP Port FTP Port
--------- --------
     8080        0
1 row selected.
+---------------------------+
| DAD virtual-path mappings |
+---------------------------+
Virtual Path                     DAD Name
-------------------------------- --------------------------------
/apex/*                          APEX
1 row selected.
+----------------+
| DAD attributes |
+----------------+
DAD Name     DAD Param                DAD Value
------------ ------------------------ ----------------------------------------
APEX         database-username        ANONYMOUS
             default-page             apex
             document-table-name      wwv_flow_file_objects$
             request-validation-funct wwv_flow_epg_include_modules.authorize
             ion
             document-procedure       wwv_flow_file_mgr.process_download
             nls-language             american_america.al32utf8
             document-path            docs
7 rows selected.
+---------------------------------------------------+
| DAD authorization:                                |
|  To use static authentication of a user in a DAD, |
|  the DAD must be authorized for the user.         |
+---------------------------------------------------+
no rows selected
+----------------------------+
| DAD authentication schemes |
+----------------------------+
DAD Name             User Name                        Auth Scheme
-------------------- -------------------------------- ------------------
APEX                 ANONYMOUS                        Anonymous
1 row selected.
+--------------------------------------------------------+
| ANONYMOUS user status:                                 |
|  To use static or anonymous authentication in any DAD, |
|  the ANONYMOUS account must be unlocked.               |
+--------------------------------------------------------+
Database User   Status
--------------- --------------------
ANONYMOUS       OPEN
1 row selected.
+-------------------------------------------------------------------+
| ANONYMOUS access to XDB repository:                               |
|  To allow public access to XDB repository without authentication, |
|  ANONYMOUS access to the repository must be allowed.              |
+-------------------------------------------------------------------+
Allow repository anonymous access?
----------------------------------
false
1 row selected.

4.6 debug XDB http server
/*
* Log levels for the global attribute "log-level"
*
* LOG_EMERG   CONSTANT PLS_INTEGER := 0;
* LOG_ALERT   CONSTANT PLS_INTEGER := 1;
* LOG_CRIT    CONSTANT PLS_INTEGER := 2;
* LOG_ERR     CONSTANT PLS_INTEGER := 3;
* LOG_WARNING CONSTANT PLS_INTEGER := 4;
* LOG_NOTICE  CONSTANT PLS_INTEGER := 5;
* LOG_INFO    CONSTANT PLS_INTEGER := 6;
* LOG_DEBUG   CONSTANT PLS_INTEGER := 7;
*/


begin
  dbms_epg.set_global_attribute(
    attr_name  => 'log-level',
    attr_value => dbms_epg.log_debug
  );
end;
/

commit
/

alter troubleshootin, it should be reset to LOG_ALERT

begin
  dbms_epg.set_global_attribute(
    attr_name  => 'log-level',
    attr_value => dbms_epg.log_alert
  );
end;
/

commit
/

5. troubleshooting

5.1 there is no page displayed when go to https://hostname:4443/apex
check if port is open from server firewall
$> service iptables status | grep 4443
check if http server is up
$> $ORACEL_HTTPSERVER_HOME/instance/instance1/ohs1/bin/emctl status
check if mod_plsql is load in httpd.conf file
check if apex is configured through dads.conf file. dads.conf file need be included in load mod_plsql portion in httpd.conf file

5.2 there is no page displayed when go to https://hostname:8080/apex
It costed me 4 hours to find out the cause.
NOT https but http. there is no https for EPG ( maybe I am wrong, but dufault one is http). so use http://hostname:8080/apex

5.3 there is http-500 error when go to http://hostname:8080/apex even though you can login as ANONYMOUS to view XDB folders.
you will also find below error in database alert file
ORA-00600: internal error code, arguments: [wpemInit_3], [ANONYMOUS], [], [], [], [], [], [], [], [], [], []

This costed me more than 4 hours to find out the cause.
Since you logged in as ANONYMOUS, the browser thinks you are access XDB folder and try to find the page as a folder dispaly of XDB. Of course it is not available.

solution: start a new browser instance or restart browser.

BTW: the best online document I found for EPG configuration and troubleshooting.
http://oraexplorer.com/2007/11/oracle-apex-in-11g-installation/

reference:
http://oraexplorer.com/2007/11/oracle-apex-in-11g-installation/
https://forums.oracle.com/forums/thread.jspa?threadID=983419
http://docs.oracle.com/cd/E23903_01/doc/doc.41/e21673/otn_install.htm#BABFICIA
http://docs.oracle.com/cd/E14373_01/install.32/e13366/db_install.htm#CIHGAGGB
http://docs.oracle.com/cd/E14373_01/install.32/e13366/db_install.htm
http://docs.oracle.com/cd/B28359_01/install.111/b28264/apex.htm
http://www.warp11.nl/2011/05/fully-freeware-apex-environment-vii-oracle-http-server-configuration/
http://docs.oracle.com/cd/E23903_01/doc/doc.41/e21673/otn_install.htm#BABEGAEJ
https://forums.oracle.com/forums/thread.jspa?threadID=913215





No comments:

Post a Comment