Installing PHP with unixODBC

Installing PHP with unixODBC

This install procedure is based on apache 1.3.6 and PHP 3.0.9. The PHP4 from beta 3 will have a configure option to use unixODBC so most of the following will be redundant.

This document assumes that unixODBC has been built and installed, in this case in the default location /usr/local, and that both Apache and PHP have been untarred in the users home directory.

  1. In the Apache directory run the following command
       ./configure --prefix=/www
    
    plus any other local config you need

  2. Create a file in /usr/local/include called odbc.h containing the following three lines
       #include <sql.h>
       #include <sqlext.h>
       #include <odbcinst.h>
    
    replacing /www with your desired apache install path

  3. Move to the PHP directory Define the following environment variables
       CFLAGS="-I/usr/local/include"
       LDFLAGS=
       CUSTOM_ODBC_LIBS="-L/usr/local/lib -lodbc"
    
    remember to export these variables
       export CFLAGS LDFLAGS CUSTOM_ODBC_LIBS 
    

  4. Configure PHP with
       ./configure --with-apache=../apache_1.3.6 --with-custom-odbc=/usr/local  --enable-track-vars
    
    plus any other local config you need then...
       make
       make install
    

  5. Go back to your apache directory, and do
       ./configure --prefix=/www --activate-module=src/modules/php3/libphp3.a
       make
       make install
    

  6. Back to the PHP directory Then to quote from the PHP INSTALL
       cp php3.ini-dist /usr/local/lib/php3.ini
       You can edit /usr/local/lib/php3.ini file to set PHP options.
       Edit your httpd.conf or srm.conf file and add:
         AddType application/x-httpd-php3 .php3
    
    
    
And that should be that.

If this is of any help to someone, good, any problems let me know.

Nick Gorham