ODBC and ASP with PHP on RedHat 7.3
I never thought the day would come when I would setup a system using something as old as RedHat 7.3 when not even RedHat 9 is supported any longer. Actually, I didn’t think I would ever setup a website using both PHP, ASP, SQL Server and odbc at the same time.
Well, around came a friend of mine with weird corporate site where ASP was mingled together with PHP. Odbc is used in both languages to call two different databases, both on SQL Server. To complicate life even further PHP pages opened ASP pages via http, inserting the ASP generated content into the output of PHP. The site also relied heavily upon GIF functionality in the GD module which is no longer supported in newer versions.
As installing and running it on a windows box failed because of compatibility issues with GD my friend asked me to try getting it to work on Linux. In hindsight it would perhaps have been easier to skip the GIF functionality from start as I soon decided to not run an old GD anyway. So firstly I changed their code to use PNG instead of GIF which went very well. At this point it would probably have worked on the Windows platform but as I am sucker for *nix I never thought twice before proceeding.
Then came the problems. Chilisoft ASP or Sun Java System Active Server Pages as it is called nowadays only supported version 7.3 of RedHat linux. I tried RH 9 first but I failed to get it to work even though there are hints here and there that it is possible to make it work. (No I haven’t tried RedHat Enterprise Linux yet and I still like RedHat) So after several nights of frustration, trying in vain to get it to work, I downloaded version 7.3 and everything worked out of the box. The admin interface is very simple and the odbc connections for Sun ONE ASP were easy to setup as well. Splendid!
Finally I had to get the odbc module working for PHP as well. I decided to go with iODBC from OpenLink Software. It was easy to build and after that I rebuilt PHP with odbc support. The problem was the drivers available. OpenLink software only had commercial drivers which to me seemed to install loads of unnecessary stuff for .NET, Mono, XML, POP3 and more.
It took me awhile to figure out that FreeTDS, that I had previously compiled and installed for SQL Server support, could be built to produce an odbc driver for iODBC. I just had to compile FreeTDS and IODBCin the right order. First the iODBC driver manager and then FreeTDS. I recompiled FreeTDS and it automatically created the odbc driver.
By this time I was quite tired and made a few mistakes with the configuration resulting in more unneeded frustration. Even so, it seems to work as well as it should. The only problem I can see now that I have it working is the lack of resources on the web describing the setup of PHP using odbc. As it is, information is scattered here and there and you have to put the bits and pieces together yourself. Is it that mostly professionals or companys use odbc and that they seldom find the time or reason to share their experiences? Anyway, in total it took me around six hours not counting the RH 7.3 installation. Tired but satisfied I could finally go home and get some sleep.
If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

