This document explains the whole configuration needed to get the connect
between MapServer CGI and an Oracle database server on a linux (Ubuntu)
box. The aim of this document is just to put a lot of googled knowledge in ONE
place. Hopefully it will preserve many of people spending analog amount of
time than I did!

This manual was written, because I spent several days googling around to get
my UMN having access to an oracle database. I’m NOT an oracle expert, so the
aim of this document is just to put a lot of googled knowledge in ONE place.
Hopefully it will preserve many of people spending analog amount of time than
I did! (Or: If you have the choice: Try PostGIS ;-))

Before we start, some basic knowledge, I didn’t know before:

MapServer can access oracle spatial as well as geodata from any oracle
locator installation! Oracle locator comes with every oracle instance, there
is no need for an extra license.

There is no need for further installation of any packages beside
oracle/oracle OCI

It is important that you know the NAME of the datasource, in this example this
is “MY_ORACLE” and will be used further on. Done that, you’re fine using
User/Password@MY_ORACLE in your mapfile to connect to the oracle database.
But first we have to do some more stuff.

It is important to set all environment variables correctly. There are one the
one hand system-wide environment variables to be set, on the other hand there
should be set some for the cgi-directory in your Apache configuration.

On Ubuntu (and on many other systems) there is the file “/etc/profile” which
sets environment variables for all users on the system (you may also dedicate
user-specific environment variables by editing the users ”.profile” file in
their home directory, but usually the oracle database users are not users of
the system with their own home)

Sometimes it is confusing WHERE to set WHAT in the splitted
apache2.conf-files. In the folder “/etc/apache2/sites_available” you find your
sites-file. If you did not do sth. Special e.g. installing virtual hosts, the
file is named “default”. In this file, the apache cgi-directory is defined.
Our file looks like this:

So you are fine now. Load the mapfile in your application and try it. If
everything goes well: Great, if not, possibly this ugly error-emssage occurs
(this one cmae by querying MapServer through the WMS interface as a
GetMap-request):

This points us towards, that there might be a problem with the connection to
the database. First of all, let’s check, if the mapfile is all right.
Therefore we use the MapServer utility program shp2img.

Let’s assume you are in the directory, where you compiled MapServer and run
shp2img:

If not, this possibly points you towards any error in your mapfile or in the
way to access the data directly. In this case, take a look at Oracle Spatial. If
there is a problem with your oracle connect, the same message as above
(MsDrawMap() ...) occurs. Check your mapfile syntax and/or the environment
settings for Oracle.

For Debian/Ubuntu it’s worth also checking the file “/etc/environment” and
test-wise to add the system variables comparable to System Variables

If the output is OK, you may have a look at the generated image (output.png).
Then your problem reduces to the access of apache to oracle home directory.
Carefully check your apache configuration. Please note, that the apache.config
file differs in several linux-distributions. For this paper we talk about
Ubuntu, which should be the same as Debian.