Download the PDF
A common PHP configuration in UNIX/Linux environments uses PHP 5.1 running on Red Hat Linux Enterprise 4 with Apache 2.2. The following table lists sources for acquiring the necessary software:
Install DataDirect Connect for ODBC
Install the DataDirect Connect for ODBC drivers. Fifteen-day evaluation copies are available at http://web.datadirect.com/techres/odbc.htmhttp://www.progress.com/products/datadirect-connect/odbc-drivers/odbc-developer-center/odbc-product-documentation.
Follow the instructions in the DataDirect Connect and Connect XE for ODBC User's Guide for setting environment variables and configuring a data source through the odbc.ini file.
Build PHP 5.1
Instructions for building PHP 5.1 as an Apache 2 shared module can be found at http://www.php.net/manual/en/install.unix.apache2.php. These instructions along with the following steps will guide you through the build process.
- Follow the instructions up to the statement: "Now, configure your PHP."
- Set the environment variable ODBC_HOME to point to your installation of the DataDirect Connect for ODBC drivers, for example:
ODBC_HOME=/opt/DataDirect/ODBC; export ODBC_HOME
- In the $ODBC_HOME/include directory, create a file named odbc.h with the following contents:
- Set the following environment variables to include DataDirect header (.h) files:
CPPFLAGS="-I$ODBC_HOME/include"; export CPPFLAGS
- Set the following environment variables to link DataDirect libraries:
CUSTOM_ODBC_LIBS="-L$ODBC_HOME/lib -lodbc -lodbcinst";
- Add the following directive to the "configure your PHP" step found in the PHP installation instructions:
Replace /home/ with the appropriate directory for your setup.
- Continue with the PHP installation instructions for the make command until you reach the apachectl start command. Before starting Apache, add the following environment variables to the envvars file found in the bin directory of Apache. For example:
An alternative is to specify the environment variables in each PHP script, such as:
Consult the Apache and PHP documentation for more information on setting environment variables.
//the rest of the connection code...
- An optional step is to verify that the PHP module can load all of the dynamic modules it requires by running an ldd command against the libphp5.so file found in the modules directory of your Apache home directory. The output should include references to the libodbc.so, libivicuxx.so, and libodbcinst.so shared object files that are found in the $ODBC_HOME/lib directory.
- After starting your Apache server, you can verify your PHP installation by running a script with the phpinfo() function such as:
- If ODBC support is included, the output of the phpinfo() function will include an ODBC section with the following settings:
Active Persistent Links
-L$ODBC_HOME/lib -lodbc –lodbcins
Note: $ODBC_HOME will be replaced with the value you specified at build time.