Install Apache and mod_owa
In order to develop PL/SQL applications on Oracle XE, we are going to need to install a web server (Apache) and a PL/SQL gateway for Apache called mod_owa. On a regular Oracle Application Server you would probably be using Oracle HTTP Server (a modified Apache) and mod_plsql, amd you should also be able to follow my future tutorials if you have this type of setup.
Once again I will be assuming throughout this guide that you have followed my Oracle XE installation tutorial. If you didn’t, you may need to change usernames, passwords and service names to fit your setup. I will be walking through the setup process on a Windows XP machine, but it should be similar on another Windows version. Let’s get started!
IMPORTANT NOTE: If you are looking for the download for mod_owa, please note that the website for it has moved since this blog post was originally written. You can now find mod_owa on the Oracle OSS website at the following URL: http://oss.oracle.com/projects/mod_owa/dist/documentation/modowa.htm. I have updated this blog post to reflect this change.
The first thing you’ll need to do is download the relevant software. The easiest way to install Apache is to download and run the installer binary from the Apache website. At the time of writing, the latest stable version of Apache available is 2.2.9, but again the process should be similar for whatever version you are installing. You can download Apache from http://httpd.apache.org/download.cgi. You will also need to grab the Apache PL/SQL Gateway Module (mod_owa) from http://oss.oracle.com/projects/mod_owa/dist/documentation/modowa.htm. Click on the link for “Zip file for Windows”, which includes the source code and binaries for the Windows version of Apache.
The first stage in setting up our PL/SQL web development environment is the installation of the Apache web server. To start the installation, run the installer package you downloaded earlier (the filename should be something like apache_2.2.9-win32-x86-no_ssl-r2.msi). The screen should look similar to the one in Figure 3a below:
Click “Next >” to continue. On the screen that follows, read the license agreement and if you are happy with the terms, select “I accept the terms in the license agreement” and click “Next >” to move on to the readme screen, from which you can simply press “Next >” again. You should now be presented with the following screen:
Unless you are installing Apache for production use, it doesn’t matter too much what you enter into Network Domain, Server Name or Administrator’s email, but be sure to select the option to Install Apache “for All Users, on Port 80, as a Service”. Installing on Port 8080 would likely cause a conflict between Apache and the Application Express software that comes with Oracle XE, which runs on port 8080. As soon as you are ready, click “Next >” to continue.
On the “Setup Type” screen, you can safely leave the default option of “Typical” selected and click “Next >” to continue with the installation. Advanced users may wish to tweak their installation using the Custom option, but for the sake of this tutorial, there is no need to do so.
The Apache installer will now ask you where to install Apache on your hard disk. By default Apache is installed into a subfolder of the Program Files folder, but I find it easier to install Apache into a folder just beneath the root of the C drive, which I usually name “httpd”. You can safely accept the default destination, but from here on I will refer to all Apache configuration files as if you chose to install to C:\httpd\. To install to this directory, click on the “Change” button as in Figure 3d, which should popup a screen like the one in Figure 3e. In the textbox for Folder Name, enter C:\httpd\ and click “OK”. This will close the popup window and return you to the screen shown in Figure 3d. You can now click on “Next >”.
You can now safely click on the “Install” button, which will start the installation process. This should not take long, especially if you are using a modern PC. During the installation you should see a screen similar to that in Figure 3f below.
When the installation has completed, simply click the “Finish” button to exit the installer. You should now have a new icon in your system tray, like the one highlighted in Figure 3g. It should have a tiny green play symbol in it. If it has a red square stop symbol instead, left-click on the icon, and from the Apache2.2 menu, click “Start” to start the Apache service.
Before we move on to installing mod_owa, we will first check that Apache is up and running and functioning correctly. To do so, open your favourite web browser (I use Firefox), enter http://localhost/ in the address bar and press enter. If Apache is working, you will see a message like in Figure 3h:
Now that we have Apache up and running, it is time to install our PL/SQL gateway, mod_owa. The first thing we need to do is to unzip the archive we downloaded earlier, usually named windows_all.zip. You don’t need to worry about where you extract the files to, as we are only really interested in one of them. When the archive has extracted, open the folder you extracted them, and go into the modowa folder. From here, double click on apache22 and right-click on mod_owa.dll and click Copy.
We will now paste this into the modules folder under the Apache installation directory. Hold down the Windows key and press R to open the Run dialog and enter C:\httpd\modules\ as shown in Figure 3i:
This will open the modules folder. Go to the Edit menu and click on Paste to put a copy of the mod_owa.dll file here. Now that we have stored the module DLL file, we now need to tell Apache to load this module into the web server and set up a new Apache Location, which will act like an Oracle Document Access Descriptor (DAD) from where we can run our PL/SQL web applications. If none of this makes any sense to you at this point, don’t worry about it, just follow the instructions closely and you’ll be fine.
To open the Apache configuration file (httpd.conf) open the Run dialog once again (Windows+R or Start->Run). This time, enter notepad c:\httpd\conf\httpd.conf and click the OK button. Notepad should launch, with the Apache config file opened and ready for editing. Scroll down to the bottom of this file (or hold down the Ctrl button and press the End button) and below all other code, insert the text from listing 3a:
LoadModule owa_module modules/mod_owa.dll
<Location /somando>
AllowOverride None
Options None
SetHandler owa_handler
OwaUserid somando/somando1
OwaNLS WE8ISO8859P1
OwaDiag COMMAND ARGS CGIENV POOL SQL MEMORY
OwaLog "/usr/local/apache/logs/mod_owa.log"
OwaPool 20
OwaStart "doc_pkg.homepage"
OwaDocProc "doc_pkg.readfile"
OwaDocPath docs
OwaUploadMax 10M
OwaCharset "iso-8859-1"
order deny,allow
allow from all
</Location>
/
Listing 3a: mod_owa Options for Apache’s httpd.conf
When you have added the text above to your httpd.conf file, save the file, and on the Apache icon in your system tray, left-click and from the Apache2.2 menu choose the “Restart” option to restart the Apache service. If all has gone well, Apache will restart just fine and you will have a play icon in your system tray icon once again. If you did not follow my guide to install Oracle XE, you will need to change the OwaUserid parameter in the text above to your own database’s connect identifier.
Once Apache has been restarted, mod_owa should now be running from http://localhost/somando. To test this, enter that address into your favourite web browser, and if mod_owa was installed you should see an error message like the one displayed in Figure 3j. If you see a different error message, you may not have installed mod_owa correctly.
The final thing we are going to do to make sure our Apache+PL/SQL setup is working correctly is create a sample application which performs a database SELECT and displays the output in a HTML table. Before we create the PL/SQL procedure to do this, let’s run the query from the SQL*Plus command line to see what data we should expect to appear in our sample app. To open SQL*Plus, go to Start -> Programs -> Oracle Database 10g Express Edition -> Run SQL Command Line. When the command line appears log on by typing CONNECT and pressing Enter. When prompted, enter your database username and password (Username: somando Password: somando1 if you followed our Oracle XE installation guide) and as soon as you are connected, enter the SQL statement from Listing 3b to query the database.
SELECT INITCAP(LOWER(object_type)) type, COUNT(*) count FROM all_objects GROUP BY object_type;
Listing 3b: Query all_objects table by object_type
You should see a result similar to that illustrated in Figure 3j:
Now we are going to create a PL/SQL procedure that will output this data to a HTML table that we can access using our web browser. From the SQL Command Line, enter the command ed test_page. Notepad will open and say that it cannot find the test_page.sql file, asking if you would like to create a new file. Click on the “Yes” button, and paste the text from Listing 3c into the Notepad window:
CREATE OR REPLACE PROCEDURE test_page IS CURSOR get_data IS SELECT INITCAP(LOWER(object_type)) type, COUNT(*) count FROM all_objects GROUP BY object_type; BEGIN htp.p('<table border="1">'); htp.p('<tr><th>Type:</th><th>Count:</th></tr>'); FOR i IN get_data LOOP htp.p('<tr><td>'||i.type||'</td><td>'||i.count||'</td></tr>'); END LOOP; htp.p('</table>'); END test_page; /
Listing 3c: Create test_page PL/SQL Procedure
When you have pasted the above code into Notepad, click on File -> Save and then quit Notepad. Back in the SQL Command Line, you should have an SQL prompt. Here, enter the command @test_page to run the script we just created. If all goes according to plan, you should see a message “Procedure created”. We can now test this procedure from our web browser by navigating to http://localhost/somando/test_page which should display something like what you see in Figure 3k below:
That’s it! You are now ready to start developing PL/SQL web applications. In our next tutorial I will look at installing Oracle SQL Developer and how to set up a development environment for PL/SQL web application programming. Very shortly I will be writing tutorials on creating some neat web applications in PL/SQL.
Click here to view a printer friendly version of this tutorial. To download this tutorial to disk, right click here and choose “Save Target As” or “Save Link As”. You will need Adobe Reader to open this file.










well…tried exactly as stated…installed XE..worked ….installed Apache..worked…BUT plsql DAD does not work….can you suggest what could be issue ? ( followed your steps word-for-word…)
Prashant Gupte
28 Dec 08 at 7:30 am
Hi Prashant,
I’ll need to know a bit more to be able to help you. When you say the DAD is not working, what is going wrong. Are you getting an Apache error message (e.g. 404 Not Found) or a PL/SQL mod_owa error message (usually output in red in the browser)? If it is the latter can you post the exact error you are getting? If it’s the former it’s likely that mod_owa is not set up correctly. Ensure that the mod_owa.dll is in the Apache modules folder and that httpd.conf is pointing to the right location. Also, make sure that you have restarted Apache after changing httpd.conf, changes to the configuration file don’t take effect until after Apache has been restarted.
Thanks for the comment and I hope this helps you get up and running,
Joe.
Joe Lennon
28 Dec 08 at 11:26 am
very interesting site, i have bookmarked your blog for future referrence, thanks
gry planszowe
17 Feb 09 at 7:14 pm
how to set up & install this on ubuntu 9.04, i’ve already try, but i get some error when restart apache and load mod_owa.so
here is the error message…
apache2: Syntax error on line 189 of /etc/apache2/apache2.conf: Syntax error on line 1 of /etc/apache2/httpd.conf: Cannot load /usr/lib/apache2/modules/mod_owa.so into server: libclntsh.so.10.1: cannot open shared object file: No such file or directory
…fail!
this is my step for installing..
1. installing apache2 via apt-get install apache2 (success)
2. installing oracle-xe via apt-get install oracle-xe(success)
3. download owa for unix(ok)
4. copy apache22/mod_owa.so from extract files to /usr/lib/apache2/modules
5 edit httpd.conf like your command
but i still get some error for this…
pls your advice
thx anyway..
arie
18 Jun 09 at 7:44 am
Regarding “Cannot load /usr/lib/apache2/modules/mod_owa.so into server: libclntsh.so.10.1″ error, you need to set LD_LIBRRAY_PATH environment variable as below. It’s the actual path of ” libclntsh.so.10.1″ file location.
export LD_LIBRARY_PATH=${ORACLE_HOME}/lib
Then restart the server and that should fix the issue.
For more info http://www.sharemation.com/~dmcmahon/modowa.htm#_unix
Balaji
16 Aug 09 at 3:23 am
I got the same problem: (ubuntu, oracle-xe)
apache2: Syntax error on line 189 of /etc/apache2/apache2.conf: Syntax error on line 1 of /etc/apache2/httpd.conf: Cannot load /usr/lib/apache2/modules/mod_owa.so into server: libclntsh.so.10.1: cannot open shared object file: No such file or directory
…fail!
export LD_LIBRARY_PATH=${ORACLE_HOME}/lib did not help
I added myuser, root, www-data, www, oracla users to ‘dba’ group. That did not help either
Any suggestions?
rakk
12 Sep 09 at 2:24 pm
That resolve my problem:
sudo ldconfig $ORACLE_HOME/lib
.. then I got this error (in the browser):
SQL ERROR
Error -1 during connect:
OCI Error: Environment not created – ORACLE_HOME not set
then I edited in /etc/init.d/apache2 that line:
ENV=”env -i LANG=C PATH=/usr/local/bin:/usr/bin:/bin”
to
ENV=”env -i LANG=C PATH=/usr/local/bin:/usr/bin:/bin ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server”
… then I got this error (in the browser):
SQL ERROR
Error 12162 during connect:
ORA-12162: TNS:net service name is incorrectly specified
then edited in /etc/init.d/apache2 that line:
ENV=”env -i LANG=C PATH=/usr/local/bin:/usr/bin:/bin”
to
ENV=”env -i LANG=C PATH=/usr/local/bin:/usr/bin:/bin ORACLE_SID=XE ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server”
Now it’s woking!
rakk
13 Sep 09 at 1:43 pm
Olá
Em premeiro, quero agradecer pelo toturail,
Mais queria saber como é possivel configurar o log de erros para mostar no ecrâ algo não esta bem na aplicação, por exemplo tem algum de parametro,
Anilton Brandão
6 Oct 09 at 7:44 pm
Hi I am not able to download the mod_owa file, can you give me another link??? Or mail it to me on my email address, roshan794@hotmail.com
roshan
13 Apr 10 at 2:32 pm
Olá, faça favor de ir tomar no cú Anilton Brandoni!
António de Pina
15 Apr 10 at 2:00 pm
The mod_owa site has moved since this article was written. You can now find it at http://oss.oracle.com/projects/mod_owa/dist/documentation/modowa.htm
Joe Lennon
12 May 10 at 3:37 pm
[...] Their is nothing in my PLSQL code that will stop you running in Oracle XE, however Oracle XE is not shipped with mod_plsql, an open source alternative to mod_plsql is mod_owa written by an Oracle employee. A colleague of mine Joe Lennon has a nice post on installing Apache and mod_owa you can find it here. [...]
EXTJS Enquiry Grid / ComboBox & Oracle includes pagenation,AJAX, sorting, searching. | Darragh Duffy – Technology & Rants
15 Jul 10 at 4:19 pm
I’ve no problem compiling source but I get an error when start apache and load mod_owa.so.
Here is the message:
“Starting httpd: httpd: Syntax error on line 430 of /aplic/httpd/conf/httpd.conf: Syntax error on line 1 of /aplic/httpd/conf.d/modowa.conf: Cannot load /aplic/httpd/modules/mod_owa.so into server: /aplic/httpd/modules/mod_owa.so: undefined symbol: owa_log_send”.
10ks.
Roger
17 Jul 10 at 11:03 pm
Hi,
Thanks for the great article!
I managed to get Apex running on Apache 2.2 and mod-owa!
Just superb!
I will post the solution soon, though have to go now.
Michiel Vermandel
13 Aug 10 at 3:32 pm
Hi Joe, Its problem regarding owa configurations with oracle database.
Lets say my http server installed in 10.10.10.10 and oracle server installed in another location let say 10.10.10.11.
So, Where, we are going to configure oracle server/TNS details?
Thanks in advance.
Vivek Jain
20 Dec 11 at 2:44 pm
Vivek,
Set up an Oracle client on the Web Server, configure the Oracle Home correctly and set up the TNS entry for the Database server. You can then set the connection string in the httpd.conf file:
OwaUserid user/password@database
Hope this helps.
Joe
Joe Lennon
22 Dec 11 at 4:21 pm
Thanks Joe, its working.
I did this for apache http server 2.2, now want to do the same for IBM Http Server 6.
Please help.
Vivek Jain
23 Dec 11 at 10:19 am